diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index cfd25a782..174b5fd47 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -27,9 +27,8 @@ module cdeps_datm_comp use NUOPC_Model , only : NUOPC_ModelGet, setVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_cday - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_config, shr_strdata_advance use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_setOrbs @@ -267,14 +266,16 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) open (newunit=nu,file=trim(nlfilename),status="old",action="read") call shr_nl_find_group_name(nu, 'datm_nml', status=ierr) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if read (nu,nml=datm_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 bcasttmp(1) = nx_global @@ -327,7 +328,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) else if (nextsw_cday_calc == 'cam6') then nextsw_cday_calc_cam7 = .false. else - call shr_sys_abort(' ERROR illegal datm nextsw_cday_calc = '//trim(nextsw_cday_calc)) + call shr_log_error(' ERROR illegal datm nextsw_cday_calc = '//trim(nextsw_cday_calc), rc=rc) + return end if ! write namelist input to standard out @@ -364,7 +366,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) trim(datamode) == 'ERA5' .or. & trim(datamode) == 'SIMPLE') then else - call shr_sys_abort(' ERROR illegal datm datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal datm datamode = '//trim(datamode), rc=rc) + return endif ! Advertise datm fields @@ -495,7 +498,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (isPresent .and. isSet) then read (cvalue,*) flds_scalar_index_nextsw_cday else - call shr_sys_abort(subname//'Need to set attribute ScalarFieldIdxNextSwCday') + call shr_log_error(subname//'Need to set attribute ScalarFieldIdxNextSwCday', rc=rc) + return endif nextsw_cday = getNextRadCDay(dayofYear, current_tod, stepno, idt, iradsw) @@ -656,7 +660,8 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod call dshr_restart_read(restfilm, rpfile, logunit, my_task, mpicom, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select end if @@ -727,7 +732,8 @@ subroutine datm_comp_run(gcomp, importState, exportState, target_ymd, target_tod my_task, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select end if @@ -830,7 +836,8 @@ subroutine datm_init_dfields(rc) case('cpl_scalars') continue case default - call shr_sys_abort(subName//'field '//trim(lfieldnames(n))//' not recognized') + call shr_log_error(subName//'field '//trim(lfieldnames(n))//' not recognized', rc=rc) + return end select end if end do diff --git a/datm/datm_datamode_cfsr_mod.F90 b/datm/datm_datamode_cfsr_mod.F90 index ec1ab7a89..9f704425a 100644 --- a/datm/datm_datamode_cfsr_mod.F90 +++ b/datm/datm_datamode_cfsr_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_cfsr_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO 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 shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_clmncep_mod.F90 b/datm/datm_datamode_clmncep_mod.F90 index 78b3bf4db..ccd75f4e3 100644 --- a/datm/datm_datamode_clmncep_mod.F90 +++ b/datm/datm_datamode_clmncep_mod.F90 @@ -4,7 +4,7 @@ module datm_datamode_clmncep_mod use ESMF , only : ESMF_STATEITEM_NOTFOUND, ESMF_LOGMSG_INFO, ESMF_StateGet, operator(/=) 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 shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_spval, shr_const_tkfrz, shr_const_pi use shr_const_mod , only : shr_const_pstd, shr_const_stebol, shr_const_rdair @@ -319,7 +319,8 @@ subroutine datm_datamode_clmncep_init_pointers(importState, exportState, sdat, r ! error check if (.not. associated(strm_wind) .or. .not. associated(strm_tbot)) then - call shr_sys_abort(trim(subname)//' ERROR: wind and tbot must be in streams for CLMNCEP') + call shr_log_error(trim(subname)//' ERROR: wind and tbot must be in streams for CLMNCEP', rc=rc) + return endif ! determine anidrmax (see below for use) @@ -380,7 +381,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) tbotmax = rtmp(2) if (mainproc) write(logunit,*) trim(subname),' tbotmax = ',tbotmax if(tbotmax <= 0) then - call shr_sys_abort(subname//'ERROR: bad value in tbotmax') + call shr_log_error(subname//'ERROR: bad value in tbotmax', rc=rc) + return endif ! determine anidrmax (see below for use) @@ -456,7 +458,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) qsat = (0.622_r8 * e)/(pbot - 0.378_r8 * e) Sa_shum(n) = qsat else - call shr_sys_abort(subname//'ERROR: cannot compute shum') + call shr_log_error(subname//'ERROR: cannot compute shum', rc=rc) + return endif !--- density --- vp = (Sa_shum(n)*pbot) / (0.622_r8 + 0.378_r8 * Sa_shum(n)) @@ -493,7 +496,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) swvdf = strm_swdn(n) * 0.50_r8 Faxa_swvdf(n) = (1._r8 - ratio_rvrf)*swvdf else - call shr_sys_abort(subName//'ERROR: cannot compute short-wave down') + call shr_log_error(subName//'ERROR: cannot compute short-wave down', rc=rc) + return endif !--- swnet: a diagnostic quantity --- @@ -517,7 +521,8 @@ subroutine datm_datamode_clmncep_advance(mainproc, logunit, mpicom, rc) Faxa_rainc(n) = strm_precn(n)*0.1_r8 Faxa_rainl(n) = strm_precn(n)*0.9_r8 else - call shr_sys_abort(subName//'ERROR: cannot compute rain and snow') + call shr_log_error(subName//'ERROR: cannot compute rain and snow', rc=rc) + return endif !--- split precip between rain & snow --- diff --git a/datm/datm_datamode_core2_mod.F90 b/datm/datm_datamode_core2_mod.F90 index 8b041f084..b874dcf98 100644 --- a/datm/datm_datamode_core2_mod.F90 +++ b/datm/datm_datamode_core2_mod.F90 @@ -17,7 +17,7 @@ module datm_datamode_core2_mod use pio , only : pio_closefile 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 shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -262,12 +262,14 @@ subroutine datm_datamode_core2_init_pointers(exportState, sdat, datamode, factor end if if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then - call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE2') + call shr_log_error(trim(subname)//'ERROR: prec and swdn must be in streams for CORE2', rc=rc) + return endif if (trim(datamode) == 'CORE2_IAF' ) then if (.not. associated(strm_tarcf)) then - call shr_sys_abort(trim(subname)//'tarcf must be in an input stream for CORE2_IAF') + call shr_log_error(trim(subname)//'tarcf must be in an input stream for CORE2_IAF', rc=rc) + return endif endif diff --git a/datm/datm_datamode_cplhist_mod.F90 b/datm/datm_datamode_cplhist_mod.F90 index ca53ed78d..c73b51efc 100644 --- a/datm/datm_datamode_cplhist_mod.F90 +++ b/datm/datm_datamode_cplhist_mod.F90 @@ -4,7 +4,6 @@ module datm_datamode_cplhist_mod use ESMF , only : ESMF_StateItem_Flag 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 shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_pointer use dshr_strdata_mod , only : shr_strdata_type diff --git a/datm/datm_datamode_era5_mod.F90 b/datm/datm_datamode_era5_mod.F90 index 187c3b5d7..dad08baf9 100644 --- a/datm/datm_datamode_era5_mod.F90 +++ b/datm/datm_datamode_era5_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_era5_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO 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 shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_gefs_mod.F90 b/datm/datm_datamode_gefs_mod.F90 index fb7a0b4dc..80d5716d8 100644 --- a/datm/datm_datamode_gefs_mod.F90 +++ b/datm/datm_datamode_gefs_mod.F90 @@ -3,7 +3,6 @@ module datm_datamode_gefs_mod use ESMF , only : ESMF_State, ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO 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 shr_sys_mod , only : shr_sys_abort use shr_precip_mod , only : shr_precip_partition_rain_snow_ramp use shr_const_mod , only : shr_const_tkfrz, shr_const_rhofw, shr_const_rdair use dshr_methods_mod , only : dshr_state_getfldptr, chkerr diff --git a/datm/datm_datamode_jra_mod.F90 b/datm/datm_datamode_jra_mod.F90 index 2e0e5ee67..13ef64ebf 100644 --- a/datm/datm_datamode_jra_mod.F90 +++ b/datm/datm_datamode_jra_mod.F90 @@ -5,7 +5,7 @@ module datm_datamode_jra_mod use ESMF , only : ESMF_StateItem_Flag, ESMF_STATEITEM_NOTFOUND, operator(/=) 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 shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi, shr_const_rdair use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -226,7 +226,8 @@ subroutine datm_datamode_jra_init_pointers(exportState, sdat, rc) ! erro check if (.not. associated(strm_prec) .or. .not. associated(strm_swdn)) then - call shr_sys_abort(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA') + call shr_log_error(trim(subname)//'ERROR: prec and swdn must be in streams for CORE_IAF_JRA', rc=rc) + return endif end subroutine datm_datamode_jra_init_pointers diff --git a/datm/datm_datamode_simple_mod.F90 b/datm/datm_datamode_simple_mod.F90 index 454bceeac..e9db91118 100644 --- a/datm/datm_datamode_simple_mod.F90 +++ b/datm/datm_datamode_simple_mod.F90 @@ -18,14 +18,14 @@ module datm_datamode_simple_mod use pio , only : pio_closefile 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 shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_date2julian use shr_const_mod , only : shr_const_tkfrz, shr_const_pi use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, dshr_fldbun_regrid, chkerr use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - + use shr_log_mod , only : shr_log_error + implicit none private ! except @@ -117,7 +117,9 @@ subroutine datm_datamode_simple_advertise(exportState, fldsexport, flds_scalar_n read (nu,nml=const_forcing_nml,iostat=ierr) close(nu) if (ierr > 0) then - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 diff --git a/dglc/dglc_datamode_noevolve_mod.F90 b/dglc/dglc_datamode_noevolve_mod.F90 index a7ed13592..608192a16 100644 --- a/dglc/dglc_datamode_noevolve_mod.F90 +++ b/dglc/dglc_datamode_noevolve_mod.F90 @@ -9,7 +9,7 @@ module dglc_datamode_noevolve_mod use ESMF , only : ESMF_VMGetCurrent, ESMF_VMBroadCast use NUOPC , only : NUOPC_Advertise, NUOPC_IsConnected use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : SHR_CONST_RHOICE, SHR_CONST_RHOSW, SHR_CONST_REARTH, SHR_CONST_TKFRZ use shr_const_mod , only : SHR_CONST_SPVAL use shr_cal_mod , only : shr_cal_datetod2string @@ -204,7 +204,8 @@ subroutine dglc_datamode_noevolve_init_pointers(NStateExp, NstateImp, rc) if (.not. NUOPC_IsConnected(NStateImp(ns), fieldName=field_in_tsrf)) then ! NOTE: the field is connected ONLY if the MED->GLC entry is in the nuopc.runconfig file ! This restriction occurs even if the field was advertised - call shr_sys_abort(trim(subname)//": MED->GLC must appear in run sequence") + call shr_log_error(trim(subname)//": MED->GLC must appear in run sequence", rc=rc) + return end if call dshr_state_getfldptr(NStateImp(ns), field_in_tsrf, fldptr1=Sl_tsrf(ns)%ptr, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -309,8 +310,8 @@ subroutine dglc_datamode_noevolve_advance(gcomp, pio_subsystem, io_type, io_form ! Create pioid and pio_iodesc at the module level inquire(file=trim(model_datafiles(ns)), exist=exists) if (.not.exists) then - write(6,'(a)')' ERROR: model input file '//trim(model_datafiles(ns))//' does not exist' - call shr_sys_abort() + call shr_log_error(' ERROR: model input file '//trim(model_datafiles(ns))//' does not exist', rc=rc) + return end if rcode = pio_openfile(pio_subsystem, pioid, io_type, trim(model_datafiles(ns)), pio_nowrite) call pio_seterrorhandling(pioid, PIO_BCAST_ERROR) diff --git a/dglc/glc_comp_nuopc.F90 b/dglc/glc_comp_nuopc.F90 index 39c6620fa..71b4583c0 100644 --- a/dglc/glc_comp_nuopc.F90 +++ b/dglc/glc_comp_nuopc.F90 @@ -28,9 +28,8 @@ module cdeps_dglc_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_string_mod , only : shr_string_listGetNum, shr_string_listGetName #ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat @@ -225,8 +224,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dglc_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,'(a,i8)') 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! Determine number of ice sheets @@ -284,7 +283,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'noevolve') then ! read stream, no import data ! do nothing else - call shr_sys_abort(' ERROR illegal dglc datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dglc datamode = '//trim(datamode), rc=rc) + return endif ! Allocate module variables @@ -362,7 +362,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (isPresent .and. isSet) then read(cvalue,*) restart_read else - call shr_sys_abort(subname//' ERROR: read restart flag must be present') + call shr_log_error(subname//' ERROR: read restart flag must be present', rc=rc) + return end if ! Get the time to interpolate the stream data to @@ -390,8 +391,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (my_task == main_task) then inquire(file=trim(model_meshfiles(ns)), exist=exists) if (.not.exists) then - write(logunit,'(a)')' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfiles(ns))//' does not exist', rc=rc) + return end if endif diff --git a/dice/dice_datamode_ssmi_mod.F90 b/dice/dice_datamode_ssmi_mod.F90 index 79c4ac372..20976c236 100644 --- a/dice/dice_datamode_ssmi_mod.F90 +++ b/dice/dice_datamode_ssmi_mod.F90 @@ -5,7 +5,6 @@ module dice_datamode_ssmi_mod use ESMF , only : ESMF_ArrayCreate, ESMF_ArrayDestroy, ESMF_GridComp 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 shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_pi, shr_const_spval, shr_const_tkfrz, shr_const_latice use shr_frz_mod , only : shr_frz_freezetemp use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index ad01ffdd0..fb204ed67 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -26,8 +26,7 @@ module cdeps_dice_comp use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, cxx=>shr_kind_cxx, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : shr_const_pi - use shr_log_mod , only : shr_log_setLogUnit - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_cal_mod , only : shr_cal_ymd2date, shr_cal_ymd2julian use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_check_restart_alarm use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock, dshr_log_clock_advance @@ -212,8 +211,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dice_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -268,7 +268,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if ( trim(datamode) == 'ssmi' .or. trim(datamode) == 'ssmi_iaf') then if (my_task == main_task) write(logunit,*) ' dice datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dice datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dice datamode = '//trim(datamode), rc=rc) + return endif ! Advertise import and export fields diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index a40685bc7..3ad783862 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -23,9 +23,8 @@ module cdeps_dlnd_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_get_stream_domain use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -204,8 +203,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=dlnd_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if bcasttmp = 0 bcasttmp(1) = nx_global @@ -248,7 +248,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (my_task == main_task) write(logunit,*) 'dlnd datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dlnd datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dlnd datamode = '//trim(datamode), rc=rc) + return end if call NUOPC_CompAttributeGet(gcomp, name='glc_nec', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/docn/docn_datamode_aquaplanet_mod.F90 b/docn/docn_datamode_aquaplanet_mod.F90 index e851e6d31..e988b6dc2 100644 --- a/docn/docn_datamode_aquaplanet_mod.F90 +++ b/docn/docn_datamode_aquaplanet_mod.F90 @@ -4,7 +4,7 @@ module docn_datamode_aquaplanet_mod 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 shr_const_mod , only : shr_const_TkFrz, shr_const_pi - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add @@ -167,7 +167,8 @@ subroutine docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_option, ! Error checks if (sst_option < 1 .or. sst_option > 10) then - call shr_sys_abort ('docn_prescribed_sst: ERROR: sst_option must be between 1 and 10') + call shr_log_error ('docn_prescribed_sst: ERROR: sst_option must be between 1 and 10', rc=rc) + return end if ! Determine So_t in degrees C @@ -305,7 +306,8 @@ subroutine docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_option, So_t(:) = So_t(:) + TkFrz else - call shr_sys_abort("ERROR: either sst_constant value or sst_option must be input") + call shr_log_error("ERROR: either sst_constant value or sst_option must be input", rc=rc) + return end if end subroutine docn_datamode_aquaplanet_advance diff --git a/docn/docn_datamode_copyall_mod.F90 b/docn/docn_datamode_copyall_mod.F90 index 1c447677d..a6628f56d 100644 --- a/docn/docn_datamode_copyall_mod.F90 +++ b/docn/docn_datamode_copyall_mod.F90 @@ -4,7 +4,6 @@ module docn_datamode_copyall_mod 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 shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal - use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_type diff --git a/docn/docn_datamode_cplhist_mod.F90 b/docn/docn_datamode_cplhist_mod.F90 index f913ad467..f22b9650c 100644 --- a/docn/docn_datamode_cplhist_mod.F90 +++ b/docn/docn_datamode_cplhist_mod.F90 @@ -4,7 +4,6 @@ module docn_datamode_cplhist_mod 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 shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal - use shr_sys_mod , only : shr_sys_abort use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_type diff --git a/docn/docn_datamode_iaf_mod.F90 b/docn/docn_datamode_iaf_mod.F90 index 7e56afd47..a4d0dc5ae 100644 --- a/docn/docn_datamode_iaf_mod.F90 +++ b/docn/docn_datamode_iaf_mod.F90 @@ -3,13 +3,11 @@ module docn_datamode_iaf_mod use ESMF , only : ESMF_SUCCESS, ESMF_LOGMSG_INFO, ESMF_LogWrite, ESMF_State 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 shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_strdata_mod , only : shr_strdata_type use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add - use pio implicit none private ! except diff --git a/docn/docn_datamode_multilev_dom_mod.F90 b/docn/docn_datamode_multilev_dom_mod.F90 index c6413f018..e292b8ade 100644 --- a/docn/docn_datamode_multilev_dom_mod.F90 +++ b/docn/docn_datamode_multilev_dom_mod.F90 @@ -4,7 +4,7 @@ module docn_datamode_multilev_dom_mod 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 shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal, shr_const_spval - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type, shr_strdata_get_stream_count @@ -168,7 +168,8 @@ subroutine docn_datamode_multilev_dom_advance(sdat, logunit, mainproc, rc) if (nlev_stream > 1) exit end do if (nlev_stream == 0) then - call shr_sys_abort(trim(subname)//" could not find vertical levels greater than 0") + call shr_log_error(trim(subname)//" could not find vertical levels greater than 0", rc=rc) + return end if allocate(stream_vlevs(nlev_stream)) stream_vlevs(:) = sdat%pstrm(stream_index)%stream_vlevs(:) @@ -210,7 +211,8 @@ subroutine docn_datamode_multilev_dom_advance(sdat, logunit, mainproc, rc) end if end do if (.not. level_found) then - call shr_sys_abort(trim(subname)//" could not find level bounds for vertical interpolation") + call shr_log_error(trim(subname)//" could not find level bounds for vertical interpolation", rc=rc) + return end if end do diff --git a/docn/docn_datamode_multilev_mod.F90 b/docn/docn_datamode_multilev_mod.F90 index 11f9dc43f..c3949a702 100644 --- a/docn/docn_datamode_multilev_mod.F90 +++ b/docn/docn_datamode_multilev_mod.F90 @@ -3,7 +3,7 @@ module docn_datamode_multilev_mod 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 shr_const_mod , only : shr_const_TkFrz, shr_const_pi, shr_const_ocn_ref_sal, shr_const_spval - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfldptr, chkerr use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add use dshr_strdata_mod , only : shr_strdata_get_stream_pointer, shr_strdata_type @@ -175,7 +175,8 @@ subroutine docn_datamode_multilev_advance(sdat, logunit, mainproc, rc) end if end do if (.not. level_found) then - call shr_sys_abort("ERROR: could not find level bounds for vertical interpolation") + call shr_log_error("ERROR: could not find level bounds for vertical interpolation", rc=rc) + return end if end do diff --git a/docn/docn_datamode_som_mod.F90 b/docn/docn_datamode_som_mod.F90 index 92e51c0f8..b3947d697 100644 --- a/docn/docn_datamode_som_mod.F90 +++ b/docn/docn_datamode_som_mod.F90 @@ -6,7 +6,6 @@ module docn_datamode_som_mod use ESMF , only : ESMF_LogWrite 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 shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_cpsw, shr_const_rhosw, shr_const_TkFrz use shr_const_mod , only : shr_const_TkFrzSw, shr_const_latice, shr_const_ocn_ref_sal use shr_const_mod , only : shr_const_zsrflyr, shr_const_pi diff --git a/docn/docn_import_data_mod.F90 b/docn/docn_import_data_mod.F90 index ff4ba7d68..ea4b423c7 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 + use shr_log_mod , only : shr_log_error ! 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 @@ -98,7 +98,8 @@ subroutine docn_get_import_fields(str, flds, rc) valid = .false. end if if (.not. valid) then - call shr_sys_abort("ERROR: invalid list = "//trim(str)) + call shr_log_error("ERROR: invalid list = "//trim(str), rc=rc) + return end if ! get number of fields in a colon delimited string list nflds = 0 diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index bb0d3e78b..7a94cd0f4 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -24,9 +24,8 @@ module cdeps_docn_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_init_from_config use dshr_mod , only : dshr_model_initphase, dshr_init, dshr_mesh_init, dshr_restart_read @@ -232,7 +231,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) close(nu) if (ierr > 0) then write(logunit,F00) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -308,7 +308,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) trim(datamode) == 'multilev_dom') then ! multilevel ocean input and sst export ! success do nothing else - call shr_sys_abort(' ERROR illegal docn datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal docn datamode = '//trim(datamode), rc=rc) + return endif ! Advertise docn fields @@ -653,7 +654,8 @@ subroutine docn_comp_run(gcomp, importState, exportState, clock, target_ymd, tar case('sst_aquap_analytic', 'sst_aquap_constant') ! Do nothing case default - call shr_sys_abort(subName//'datamode '//trim(datamode)//' not recognized') + call shr_log_error(subName//'datamode '//trim(datamode)//' not recognized', rc=rc) + return end select endif diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index 520057d90..739bc1490 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -25,9 +25,8 @@ module cdeps_drof_comp use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs use shr_const_mod , only : SHR_CONST_SPVAL - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, dshr_state_diagnose, chkerr, memcheck use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance, shr_strdata_get_stream_domain use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -199,8 +198,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) read (nu,nml=drof_nml,iostat=ierr) close(nu) if (ierr > 0) then - write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + rc = ierr + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -242,7 +242,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (mainproc) write(logunit,*) 'drof datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal drof datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal drof datamode = '//trim(datamode), rc=rc) + return end if call dshr_fldList_add(fldsExport, trim(flds_scalar_name)) diff --git a/dshr/dshr_dfield_mod.F90 b/dshr/dshr_dfield_mod.F90 index 2f3b33d69..bbd411572 100644 --- a/dshr/dshr_dfield_mod.F90 +++ b/dshr/dshr_dfield_mod.F90 @@ -3,7 +3,7 @@ module dshr_dfield_mod use ESMF , only : ESMF_State, ESMF_FieldBundle, ESMF_MAXSTR, ESMF_SUCCESS use ESMF , only : ESMF_FieldBundleGet, ESMF_ITEMORDER_ADDORDER, ESMF_Field, ESMF_FieldGet use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_get_stream_count, shr_strdata_get_stream_fieldbundle use dshr_methods_mod , only : dshr_state_getfldptr, dshr_fldbun_getfieldn, dshr_field_getfldptr, dshr_fldbun_getFldPtr use dshr_methods_mod , only : chkerr @@ -77,7 +77,8 @@ subroutine dshr_dfield_add_1d(dfields, sdat, state_fld, strm_fld, state, logunit allocate(dfield_new, stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%next => dfields dfields => dfield_new @@ -154,7 +155,8 @@ subroutine dshr_dfield_add_1d_stateptr(dfields, sdat, state_fld, strm_fld, state allocate(dfield_new, stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%next => dfields dfields => dfield_new @@ -253,7 +255,8 @@ subroutine dshr_dfield_add_2d(dfields, sdat, state_fld, strm_flds, state, & endif if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! determine stream fldnames array @@ -261,12 +264,14 @@ subroutine dshr_dfield_add_2d(dfields, sdat, state_fld, strm_flds, state, & allocate(dfield_new%stream_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif allocate(dfield_new%fldbun_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif dfield_new%stream_indices(:) = 0 dfield_new%fldbun_indices(:) = 0 @@ -358,7 +363,8 @@ subroutine dshr_dfield_add_2d_stateptr(dfields, sdat, state_fld, strm_flds, stat endif if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! determine stream fldnames array @@ -367,12 +373,14 @@ subroutine dshr_dfield_add_2d_stateptr(dfields, sdat, state_fld, strm_flds, stat allocate(dfield_new%stream_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif allocate(dfield_new%fldbun_indices(nflds), stat=status) if (status /= 0) then write(msgstr,*)'allocation error ',__LINE__,':',__FILE__ - call shr_sys_abort(msgstr) + call shr_log_error(msgstr, rc=rc) + return endif ! loop through the field names in strm_flds diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 7073ea923..39822f051 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -32,8 +32,7 @@ module dshr_mod use ESMF , only : ESMF_Region_Flag, ESMF_REGION_TOTAL, ESMF_MAXSTR, ESMF_RC_NOT_VALID use ESMF , only : ESMF_UtilStringUpperCase use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cx=>shr_kind_cx, cxx=>shr_kind_cxx, i8=>shr_kind_i8 - use shr_sys_mod , only : shr_sys_abort - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian, shr_cal_calendarname use shr_cal_mod , only : shr_cal_datetod2string, shr_cal_date2julian use shr_const_mod , only : shr_const_spval, shr_const_cday @@ -89,7 +88,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 @@ -101,7 +100,8 @@ 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') + call shr_log_error(trim(subname)//' state or clock not created', rc=rc) + return endif ! Switch to IPDv01 by filtering all other phaseMap entries @@ -300,7 +300,8 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo if (isPresent .and. isSet) then read(cvalue,*) read_restart else - call shr_sys_abort(subname//' ERROR: read restart flag must be present') + call shr_log_error(subname//' ERROR: read restart flag must be present', rc=rc) + return end if ! obtain the single column lon and lat @@ -332,12 +333,14 @@ subroutine dshr_mesh_init(gcomp, sdat, nullstr, logunit, compname, model_nxg, mo inquire(file=trim(model_meshfile), exist=exists) if (.not.exists) then write(logunit, *)' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_meshfile '//trim(model_meshfile)//' does not exist', rc=rc) + return end if inquire(file=trim(model_maskfile), exist=exists) if (.not.exists) then write(logunit, *)' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist' - call shr_sys_abort(trim(subname)//' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist') + call shr_log_error(trim(subname)//' ERROR: model_maskfile '//trim(model_maskfile)//' does not exist', rc=rc) + return end if endif @@ -438,7 +441,8 @@ subroutine dshr_mesh_create_scol(gcomp, compname, scol_lon, scol_lat, & if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) model_frac(1) else - call shr_sys_abort('ERROR: currently component '//trim(compname)//' is not supported for single column') + call shr_log_error('ERROR: currently component '//trim(compname)//' is not supported for single column', rc=rc) + return end if ! Use center and come up with arbitrary area delta lon and lat = .1 degree @@ -683,10 +687,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optDate) if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + call shr_log_error(subname//trim(option)//' requires opt_ymd', rc=rc) + return end if if (lymd < 0 .or. ltod < 0) then - call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') + call shr_log_error(subname//trim(option)//'opt_ymd, opt_tod invalid', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -696,13 +702,16 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optIfdays0) if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') + call shr_log_error(subname//trim(option)//' requires opt_ymd', rc=rc) + return end if if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -712,10 +721,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSteps) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -723,8 +734,14 @@ subroutine dshr_alarm_init( clock, alarm, option, & update_nextalarm = .true. case (optNStep) - if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') - if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') + if (.not.present(opt_n)) then + call shr_log_error(subname//trim(option)//' requires opt_n',rc=rc) + return + endif + if (opt_n <= 0) then + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return + endif call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return AlarmInterval = AlarmInterval * opt_n @@ -732,10 +749,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSeconds) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -744,10 +763,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNSecond) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -757,20 +778,24 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMinutes) call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if AlarmInterval = AlarmInterval * opt_n update_nextalarm = .true. case (optNMinute) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -779,10 +804,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNHours) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -791,10 +818,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNHour) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -803,10 +832,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNDays) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -815,10 +846,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNDay) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -827,10 +860,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMonths) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -839,10 +874,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNMonth) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -858,10 +895,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNYears) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -870,10 +909,12 @@ subroutine dshr_alarm_init( clock, alarm, option, & case (optNYear) if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') + call shr_log_error(subname//trim(option)//' requires opt_n', rc=rc) + return end if if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') + call shr_log_error(subname//trim(option)//' invalid opt_n', rc=rc) + return end if call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -888,7 +929,8 @@ subroutine dshr_alarm_init( clock, alarm, option, & update_nextalarm = .true. case default - call shr_sys_abort(subname//'unknown option '//trim(option)) + call shr_log_error(subname//'unknown option '//trim(option), rc=rc) + return end select ! -------------------------------------------------------------------------------- @@ -935,7 +977,8 @@ subroutine dshr_time_init( Time, ymd, cal, tod, rc) rc = ESMF_SUCCESS if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then - call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) + call shr_log_error( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds', rc=rc ) + return end if tdate = abs(ymd) diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index 61150fedd..07e6dc50e 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -23,9 +23,8 @@ module cdeps_dwav_comp use NUOPC_Model , only : model_label_Finalize => label_Finalize use NUOPC_Model , only : NUOPC_ModelGet, SetVM use shr_kind_mod , only : r8=>shr_kind_r8, i8=>shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort use shr_cal_mod , only : shr_cal_ymd2date - use shr_log_mod , only : shr_log_setLogUnit + use shr_log_mod , only : shr_log_setLogUnit, shr_log_error use dshr_methods_mod , only : dshr_state_getfldptr, chkerr, memcheck, dshr_state_diagnose use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_advance use dshr_strdata_mod , only : shr_strdata_init_from_config @@ -198,7 +197,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) close(nu) if (ierr > 0) then write(logunit,*) 'ERROR: reading input namelist, '//trim(nlfilename)//' iostat=',ierr - call shr_sys_abort(subName//': namelist read error '//trim(nlfilename)) + call shr_log_error(subName//': namelist read error '//trim(nlfilename), rc=rc) + return end if ! write namelist input to standard out @@ -240,7 +240,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(datamode) == 'copyall') then if (my_task == main_task) write(logunit,*) 'dwav datamode = ',trim(datamode) else - call shr_sys_abort(' ERROR illegal dwav datamode = '//trim(datamode)) + call shr_log_error(' ERROR illegal dwav datamode = '//trim(datamode), rc=rc) + return end if call dwav_comp_advertise(importState, exportState, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/share/shr_abort_mod.F90 b/share/shr_abort_mod.F90 index 6e3a90680..b651db2a2 100644 --- a/share/shr_abort_mod.F90 +++ b/share/shr_abort_mod.F90 @@ -7,10 +7,7 @@ module shr_abort_mod ! (shr_sys_abort, shr_sys_backtrace). (This is for consistency with older code, from ! when these routines were defined in shr_sys_mod.) - use, intrinsic :: iso_fortran_env, only: output_unit, error_unit - use shr_kind_mod, only : shr_kind_in, shr_kind_cx - use shr_log_mod , only : s_logunit => shr_log_Unit #ifdef CPRNAG ! NAG does not provide this as an intrinsic, but it does provide modules @@ -36,11 +33,12 @@ module shr_abort_mod !=============================================================================== subroutine shr_abort_abort(string,rc, line, file) use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT + use shr_log_mod, only : shr_log_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(inout), optional :: rc ! error code integer(shr_kind_in), intent(in), optional :: line character(len=*), intent(in), optional :: file @@ -58,9 +56,7 @@ subroutine shr_abort_abort(string,rc, line, file) write(local_string, *) trim(local_string), ' rc=',rc endif - call print_error_to_logs("ERROR", local_string) - - call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file) + call shr_log_error(local_string, rc=rc, line=line, file=file) call shr_abort_backtrace() @@ -120,41 +116,7 @@ end subroutine xl_trbk #endif - flush(error_unit) - end subroutine shr_abort_backtrace !=============================================================================== - !=============================================================================== - subroutine print_error_to_logs(error_type, message) - ! This routine prints error messages to s_logunit (which is standard output - ! for most tasks in CESM) and also to standard error if s_logunit is a - ! file. - ! - ! It also flushes these output units. - - character(len=*), intent(in) :: error_type, message - - integer, allocatable :: log_units(:) - - integer :: i - - if (s_logunit == output_unit .or. s_logunit == error_unit) then - ! If the log unit number is standard output or standard error, just - ! print to that. - allocate(log_units(1), source=[s_logunit]) - else - ! Otherwise print the same message to both the log unit and standard - ! error. - allocate(log_units(2), source=[error_unit, s_logunit]) - end if - - do i = 1, size(log_units) - write(log_units(i),*) trim(error_type), ": ", trim(message) - flush(log_units(i)) - end do - - end subroutine print_error_to_logs - !=============================================================================== - end module shr_abort_mod diff --git a/share/shr_log_mod.F90 b/share/shr_log_mod.F90 index a7e4c70e3..306c00752 100644 --- a/share/shr_log_mod.F90 +++ b/share/shr_log_mod.F90 @@ -16,7 +16,7 @@ module shr_log_mod use shr_kind_mod, only: shr_kind_in, shr_kind_cx use shr_strconvert_mod, only: toString - use, intrinsic :: iso_fortran_env, only: output_unit + use, intrinsic :: iso_fortran_env, only: output_unit, error_unit implicit none private @@ -31,6 +31,7 @@ module shr_log_mod public :: shr_log_OOBMsg public :: shr_log_setLogUnit public :: shr_log_getLogUnit + public :: shr_log_error ! !PUBLIC DATA MEMBERS: @@ -117,4 +118,49 @@ subroutine shr_log_getLogUnit(unit) end subroutine shr_log_getLogUnit + subroutine shr_log_error(string, rc, line, file) + use esmf, only : ESMF_LOGWRITE, ESMF_LOGMSG_ERROR, ESMF_FINALIZE, ESMF_END_ABORT, ESMF_FAILURE, ESMF_SUCCESS + ! This routine prints error messages to shr_log_unit (which is standard output + ! for most tasks in CESM), to the ESMF PET files and to standard error if shr_log_unit is a + ! file. Sets rc to ESMF_FAILURE on return. + + !----- arguments ----- + character(len=*) , intent(in) :: string ! error message string + integer(shr_kind_in), intent(inout), optional :: rc ! error code + integer(shr_kind_in), intent(in), optional :: line + character(len=*), intent(in), optional :: file + + ! Local version of the string. + ! (Gets a default value if string is not present.) + character(len=shr_kind_cx) :: local_string + integer, allocatable :: log_units(:) + integer :: i + !------------------------------------------------------------------------------- + + local_string = trim(string) + if(present(rc)) then + if (rc /= ESMF_SUCCESS) then + write(local_string, *) trim(local_string), ' rc=',rc + endif + rc = ESMF_FAILURE + endif + + call ESMF_LogWrite(local_string, ESMF_LOGMSG_ERROR, line=line, file=file) + if (shr_log_unit == output_unit .or. shr_log_unit == error_unit) then + ! If the log unit number is standard output or standard error, just + ! print to that. + allocate(log_units(1), source=[shr_log_unit]) + else + ! Otherwise print the same message to both the log unit and standard + ! error. + allocate(log_units(2), source=[error_unit, shr_log_unit]) + end if + + do i = 1, size(log_units) + write(log_units(i),*) trim(local_string) + flush(log_units(i)) + end do + + end subroutine shr_log_error + end module shr_log_mod diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index c5aa946d1..59500d11d 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -13,7 +13,7 @@ module dshr_methods_mod 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 + use shr_log_mod , only : shr_log_error implicit none public @@ -108,6 +108,7 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc) character(len=*),parameter :: subname='(dshr_state_diagnose)' ! ---------------------------------------------- + rc = ESMF_SUCCESS call ESMF_StateGet(state, itemCount=fieldCount, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return allocate(lfieldnamelist(fieldCount)) @@ -140,7 +141,8 @@ subroutine dshr_state_diagnose(State, flds_scalar_name, string, rc) write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) end if @@ -176,7 +178,8 @@ 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 shr_sys_abort(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ") + call shr_log_error(trim(subname)//": ERROR field "//trim(fldname)//" not in FB ", rc=rc) + return endif call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -184,16 +187,18 @@ 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 shr_sys_abort(trim(subname)//": ERROR missing rank=2 array ", & - line=__LINE__, file=u_FILE_u) + call shr_log_error(trim(subname)//": ERROR missing rank=2 array ", & + line=__LINE__, file=u_FILE_u, rc=rc) + return 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 shr_sys_abort(trim(subname)//": ERROR missing rank=1 array ", & - line=__LINE__, file=u_FILE_u) + call shr_log_error(trim(subname)//": ERROR missing rank=1 array ", & + line=__LINE__, file=u_FILE_u, rc=rc) + return endif call ESMF_FieldGet(lfield, farrayptr=fldptr1, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return @@ -332,7 +337,8 @@ 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 shr_sys_abort(trim(subname)//": ERROR fieldnum > fieldCount ") + call shr_log_error(trim(subname)//": ERROR fieldnum > fieldCount ", rc=rc) + return endif allocate(lfieldnamelist(fieldCount)) @@ -368,7 +374,8 @@ 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 shr_sys_abort(trim(subname)//" Error checking field: "//trim(fldname)) + call shr_log_error(trim(subname)//" Error checking field: "//trim(fldname), rc=rc) + return endif if (isPresent) then @@ -423,7 +430,8 @@ subroutine dshr_fldbun_Field_diagnose(FB, fieldname, string, rc) write(msgString,'(A,a)') trim(subname)//' '//trim(lstring)//': '//trim(fieldname)," no data" endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) @@ -492,7 +500,8 @@ subroutine dshr_fldbun_diagnose(FB, string, rc) endif else - call shr_sys_abort(trim(subname)//": ERROR rank not supported ") + call shr_log_error(trim(subname)//": ERROR rank not supported ", rc=rc) + return endif call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) enddo @@ -542,7 +551,8 @@ 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 shr_sys_abort(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc) + call shr_log_error(trim(subname)//": field "//trim(name)//" has no data not allocated ", rc=rc) + return else call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) endif @@ -551,9 +561,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 shr_sys_abort(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE + call shr_log_error(trim(subname)//": ERROR missing rank=2 array for "//trim(name), & + line=__LINE__, file=u_FILE_u, rc=rc) return endif call ESMF_FieldGet(field, farrayptr=fldptr2, rc=rc) @@ -561,9 +570,8 @@ subroutine dshr_field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) lrank = 2 else if (.not.present(fldptr1)) then - call shr_sys_abort(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & - line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE + call shr_log_error(trim(subname)//": ERROR missing rank=1 array for "//trim(name), & + line=__LINE__, file=u_FILE_u, rc=rc) return endif call ESMF_FieldGet(field, farrayptr=fldptr1, rc=rc) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index c9ba174a2..4f04ab5f5 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -22,7 +22,7 @@ module dshr_strdata_mod use ESMF , only : ESMF_LOGMSG_INFO, ESMF_LogWrite use shr_kind_mod , only : r8=>shr_kind_r8, r4=>shr_kind_r4, i2=>shr_kind_I2 use shr_kind_mod , only : cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx, cx=>shr_kind_cx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : shr_const_pi, shr_const_cDay, shr_const_spval use shr_cal_mod , only : shr_cal_calendarname, shr_cal_timeSet use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian @@ -44,7 +44,8 @@ module dshr_strdata_mod use dshr_tinterp_mod , only : shr_tInterp_getCosz, shr_tInterp_getAvgCosz, shr_tInterp_getFactors use dshr_methods_mod , only : dshr_fldbun_getfldptr, dshr_fldbun_getfieldN, dshr_fldbun_fldchk, chkerr use dshr_methods_mod , only : dshr_fldbun_diagnose, dshr_fldbun_regrid, dshr_field_getfldptr - + use shr_sys_mod , only : shr_sys_abort + use pio , only : file_desc_t, iosystem_desc_t, io_desc_t, var_desc_t use pio , only : pio_openfile, pio_closefile, pio_nowrite use pio , only : pio_seterrorhandling, pio_initdecomp, pio_freedecomp @@ -389,7 +390,6 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) type(ESMF_CalKind_Flag) :: esmf_caltype ! esmf calendar type character(CS) :: calendar ! calendar name integer :: ns ! stream index - integer :: m ! generic index character(CX) :: fileName ! generic file name integer :: nfld ! loop stream field index type(ESMF_Field) :: lfield ! temporary @@ -426,8 +426,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) if (filename /= 'none' .and. mainproc) then inquire(file=trim(filename),exist=fileExists) if (.not. fileExists) then - write(sdat%stream(1)%logunit,'(a)') "ERROR: file does not exist: "//trim(fileName) - call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName)) + call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName), rc=rc) + return end if endif ! @@ -599,7 +599,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) else if (trim(sdat%stream(ns)%mapalgo) == 'none') then ! single point stream data, no action required. else - call shr_sys_abort('ERROR: map algo '//trim(sdat%stream(ns)%mapalgo)//' is not supported') + call shr_log_error('ERROR: map algo '//trim(sdat%stream(ns)%mapalgo)//' is not supported', rc=rc) + return end if end if @@ -616,17 +617,18 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) ! check that for now u and v are only for single level fields if (stream_nlev > 1) then ! TODO: add support for u and v for multi level fields - call shr_sys_abort(subname//': vector fields are not currently supported for multi-level fields') + call shr_log_error(subname//': vector fields are not currently supported for multi-level fields', rc=rc) + return end if ! check that stream vector names are valid if (.not. shr_string_listIsValid(stream_vector_names)) then - write(sdat%stream(1)%logunit,*) trim(subname),' vec fldlist invalid m=',m,trim(stream_vector_names) - call shr_sys_abort(subname//': vec fldlist invalid:'//trim(stream_vector_names)) + call shr_log_error(subname//': vec fldlist invalid:'//trim(stream_vector_names), rc=rc) + return endif ! check that only 2 fields are contained for any vector pairing if (shr_string_listGetNum(stream_vector_names) /= 2) then - write(sdat%stream(1)%logunit,*) trim(subname),' vec fldlist ne 2 m=',m,trim(stream_vector_names) - call shr_sys_abort(subname//': vec fldlist ne 2:'//trim(stream_vector_names)) + call shr_log_error(subname//': vec fldlist ne 2:'//trim(stream_vector_names), rc=rc) + return endif ! create stream vector field sdat%pstrm(ns)%field_stream_vector = ESMF_FieldCreate(stream_mesh, & @@ -649,7 +651,8 @@ subroutine shr_strdata_init(sdat, model_clock, stream_name, rc) else if (esmf_caltype == ESMF_CALKIND_GREGORIAN) then sdat%model_calendar = trim(shr_cal_gregorian) else - call shr_sys_abort(subname//" ERROR bad ESMF calendar name "//trim(calendar)) + call shr_log_error(subname//" ERROR bad ESMF calendar name "//trim(calendar), rc=rc) + return end if ! print sdat output @@ -788,7 +791,8 @@ subroutine shr_strdata_get_stream_domain(sdat, stream_index, fldname, flddata, r flddata(:) = data_double(:) deallocate(data_double) else - call shr_sys_abort(subName//"ERROR: only real and double types are supported for stream domain read") + call shr_log_error(subName//"ERROR: only real and double types are supported for stream domain read", rc=rc) + return end if ! Free the memory associate with the iodesc and close the file @@ -969,7 +973,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! TODO: need to put in capability to read all stream data at once case default write(logunit,F00) "ERROR: Unsupported readmode : ", trim(sdat%stream(ns)%readmode) - call shr_sys_abort(subName//"ERROR: Unsupported readmode: "//trim(sdat%stream(ns)%readmode)) + call shr_log_error(subName//"ERROR: Unsupported readmode: "//trim(sdat%stream(ns)%readmode), rc=rc) + return end select if (debug > 0 .and. sdat%mainproc) then @@ -996,7 +1001,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! case (3), abort write(logunit,*) trim(subname),' ERROR: mismatch calendar ', & trim(sdat%model_calendar),':',trim(sdat%stream(ns)%calendar) - call shr_sys_abort(trim(subname)//' ERROR: mismatch calendar ') + call shr_log_error(trim(subname)//' ERROR: mismatch calendar ', rc=rc) + return endif else ! calendars are the same if(trim(sdat%model_calendar) == trim(shr_cal_gregorian)) then @@ -1053,7 +1059,8 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit write(6,*) trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', & sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB - call shr_sys_abort(trim(subName)//' ERROR dt limit for stream, see atm.log output') + call shr_log_error(trim(subName)//' ERROR dt limit for stream, see atm.log output', rc=rc) + return endif endif endif @@ -1511,8 +1518,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (sdat%mainproc) then inquire(file=trim(fileName),exist=fileExists) if (.not. fileExists) then - write(sdat%stream(1)%logunit,F00) "ERROR: file does not exist: ", trim(fileName) - call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName)) + call shr_log_error(subName//"ERROR: file does not exist: "//trim(fileName), rc=rc) + return end if endif @@ -1557,7 +1564,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (stream_nlev == 1) then allocate(dataptr1d(1)) else - call shr_sys_abort("ERROR: multi-level streams always require a stream mesh") + call shr_log_error("ERROR: multi-level streams always require a stream mesh", rc=rc) + return end if end if @@ -1617,11 +1625,15 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & else if (pio_iovartype == PIO_SHORT) then rcode = pio_get_att(pioid, varid, "scale_factor", scale_factor) if(rcode /= PIO_NOERR) then - call shr_sys_abort('DATATYPE PIO_SHORT requires attributes scale_factor') + rc = rcode + call shr_log_error('DATATYPE PIO_SHORT requires attributes scale_factor', rc=rc) + return endif rcode = pio_get_att(pioid, varid, "add_offset", add_offset) if(rcode /= PIO_NOERR) then - call shr_sys_abort('DATATYPE PIO_SHORT requires attributes add_offset') + rc = rcode + call shr_log_error('DATATYPE PIO_SHORT requires attributes add_offset', rc=rc) + return endif rcode = pio_get_att(pioid, varid, "_FillValue", fillvalue_i2) endif @@ -1647,14 +1659,17 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/),count=(/1,1,1,1/), ival=data_real2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_real2d == fillvalue_r4)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1679,14 +1694,17 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/),count=(/1,1,1/), ival=data_real1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_real1d == fillvalue_r4)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do n=1,size(dataptr1d) @@ -1712,14 +1730,16 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/), count=(/1,1,1,1/), ival=data_dbl2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in 2d double variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in 2d double variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_dbl2d == fillvalue_r8)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do lev = 1,stream_nlev do n = 1,size(dataptr2d, dim=2) @@ -1744,14 +1764,16 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/), count=(/1,1,1/), ival=data_dbl1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then ! Single point streams are not allowed to have missing values if (stream%mapalgo == 'none' .and. any(data_dbl1d == fillvalue_r8)) then write(errmsg,*) ' ERROR: _Fillvalue found in stream input variable: '// trim(per_stream%fldlist_stream(nf)) - if(sdat%mainproc) write(sdat%stream(1)%logunit,*) trim(errmsg) - call shr_sys_abort(errmsg) + call shr_log_error(errmsg, rc=rc) + return endif do n = 1,size(dataptr1d) if (.not. shr_infnan_isnan(data_dbl1d(n)) .and. data_dbl1d(n) .ne. fillvalue_r8) then @@ -1778,7 +1800,9 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,1,nt/), count=(/1,1,1,1/), ival=data_short2d) end if if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in 2d short variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in 2d short variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then do lev = 1,stream_nlev @@ -1804,7 +1828,9 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & rcode = pio_get_var(pioid, varid,start=(/1,1,nt/),count=(/1,1,1/), ival=data_short1d) endif if ( rcode /= PIO_NOERR ) then - call shr_sys_abort(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf))) + rc = rcode + call shr_log_error(' ERROR: reading in variable: '// trim(per_stream%fldlist_stream(nf)), rc=rc) + return end if if (handlefill) then do n=1,lsize @@ -1825,7 +1851,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & ! ----------------------------- ! pio_iovartype is not supported ! ----------------------------- - call shr_sys_abort(subName//"ERROR: only double, real and short types are supported for stream read") + call shr_log_error(subName//"ERROR: only double, real and short types are supported for stream read", rc=rc) + return end if @@ -1881,7 +1908,8 @@ subroutine shr_strdata_readstrm(sdat, per_stream, stream, fldbun_data, & if (chkerr(rc,__LINE__,u_FILE_u)) return if (.not. ESMF_FieldIsCreated(per_stream%field_stream_vector)) then - call shr_sys_abort('ERROR: per_stream%field_stream_vector has not been created') + call shr_log_error('ERROR: per_stream%field_stream_vector has not been created', rc=rc) + return end if call ESMF_FieldRegrid(per_stream%field_stream_vector, field_vector_dst, per_stream%routehandle, & @@ -2052,12 +2080,14 @@ subroutine shr_strdata_set_stream_iodesc(sdat, per_stream, fldname, pioid, rc) per_stream%stream_pio_iodesc) else write(6,*)'ERROR: dimlens= ',dimlens - call shr_sys_abort(trim(subname)//' dimlens = 4 assumes a time dimension') + call shr_log_error(trim(subname)//' dimlens = 4 assumes a time dimension', rc=rc) + return end if else write(6,*)'ERROR: dimlens= ',dimlens - call shr_sys_abort(trim(subname)//' only ndims of 2 and 3 and 4 are currently supported') + call shr_log_error(trim(subname)//' only ndims of 2 and 3 and 4 are currently supported', rc=rc) + return end if ! deallocate memory diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index e73fb19ca..64c7f542b 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -16,7 +16,7 @@ module dshr_stream_mod ! ------------------------------------------------------------------------------- use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx, cx=>shr_kind_cx - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_const_mod , only : shr_const_cday use shr_string_mod , only : shr_string_leftalign_and_convert_tabs, shr_string_parseCFtunit use shr_cal_mod , only : shr_cal_noleap @@ -34,7 +34,7 @@ module dshr_stream_mod #ifdef CESMCOUPLED use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat #endif - + use shr_sys_mod , only : shr_sys_abort implicit none private ! default private @@ -210,7 +210,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu Sdoc => parseFile(streamfilename, iostat=status) if (status /= 0) then - call shr_sys_abort("Could not parse file "//trim(streamfilename)) + call shr_log_error("Could not parse file "//trim(streamfilename), rc=rc) + return endif streamlist => getElementsByTagname(Sdoc, "stream_info") nstrms = getLength(streamlist) @@ -228,7 +229,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (streamdat(i)%taxmode /= shr_stream_taxis_cycle .and. & streamdat(i)%taxmode /= shr_stream_taxis_extend .and. & streamdat(i)%taxmode /= shr_stream_taxis_limit) then - call shr_sys_abort("tintalgo must have a value of either cycle, extend or limit") + call shr_log_error("tintalgo must have a value of either cycle, extend or limit", rc=rc) + return end if endif @@ -241,7 +243,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu streamdat(i)%mapalgo /= shr_stream_mapalgo_consf .and. & streamdat(i)%mapalgo /= shr_stream_mapalgo_consd .and. & streamdat(i)%mapalgo /= shr_stream_mapalgo_none) then - call shr_sys_abort("mapaglo must have a value of either bilinear, redist, nn, consf or consd") + call shr_log_error("mapaglo must have a value of either bilinear, redist, nn, consf or consd", rc=rc) + return end if endif @@ -253,7 +256,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu streamdat(i)%tInterpAlgo /= shr_stream_tinterp_nearest .and. & streamdat(i)%tInterpAlgo /= shr_stream_tinterp_linear .and. & streamdat(i)%tInterpAlgo /= shr_stream_tinterp_coszen) then - call shr_sys_abort("tintalgo must have a value of either lower, upper, nearest, linear or coszen") + call shr_log_error("tintalgo must have a value of either lower, upper, nearest, linear or coszen", rc=rc) + return end if endif @@ -266,21 +270,24 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if(associated(p)) then call extractDataContent(p, streamdat(i)%yearFirst) else - call shr_sys_abort("yearFirst must be provided") + call shr_log_error("yearFirst must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "year_last"), 0) if(associated(p)) then call extractDataContent(p, streamdat(i)%yearLast) else - call shr_sys_abort("yearLast must be provided") + call shr_log_error("yearLast must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "year_align"), 0) if(associated(p)) then call extractDataContent(p, streamdat(i)%yearAlign) else - call shr_sys_abort("yearAlign must be provided") + call shr_log_error("yearAlign must be provided", rc=rc) + return endif p=> item(getElementsByTagname(streamnode, "dtlimit"), 0) @@ -297,14 +304,16 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (associated(p)) then call extractDataContent(p, streamdat(i)%meshfile) else - call shr_sys_abort("mesh file name must be provided") + call shr_log_error("mesh file name must be provided", rc=rc) + return endif p => item(getElementsByTagname(streamnode, "vectors"), 0) if (associated(p)) then call extractDataContent(p, streamdat(i)%stream_vectors) else - call shr_sys_abort("stream vectors must be provided") + call shr_log_error("stream vectors must be provided", rc=rc) + return endif ! Determine name of vertical dimension @@ -312,13 +321,15 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu if (associated(p)) then call extractDataContent(p, streamdat(i)%lev_dimname) else - call shr_sys_abort("stream vertical level dimension name must be provided") + call shr_log_error("stream vertical level dimension name must be provided", rc=rc) + return endif ! Determine input data files p => item(getElementsByTagname(streamnode, "datafiles"), 0) if (.not. associated(p)) then - call shr_sys_abort("stream data files must be provided") + call shr_log_error("stream data files must be provided", rc=rc) + return endif filelist => getElementsByTagname(p,"file") streamdat(i)%nfiles = getLength(filelist) @@ -428,7 +439,8 @@ subroutine shr_stream_init_from_xml(streamfilename, streamdat, isroot_task, logu ! Error check if (trim(streamdat(i)%taxmode) == shr_stream_taxis_extend .and. streamdat(i)%dtlimit < 1.e10) then - call shr_sys_abort(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30") + call shr_log_error(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30", rc=rc) + return end if ! initialize flag that stream has been set streamdat(i)%init = .true. @@ -625,7 +637,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, if( nstrms > 0 ) then allocate(streamdat(nstrms)) else - call shr_sys_abort("no stream_info in config file "//trim(streamfilename)) + call shr_log_error("no stream_info in config file "//trim(streamfilename), rc=rc) + return endif ! fill in non-default values for the streamdat attributes @@ -647,21 +660,24 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearFirst,label="yearFirst"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearFirst must be provided") + call shr_log_error("yearFirst must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="yearLast"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearLast,label="yearLast"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearLast must be provided") + call shr_log_error("yearLast must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="yearAlign"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%yearAlign,label="yearAlign"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("yearAlign must be provided") + call shr_log_error("yearAlign must be provided", rc=rc) + return endif call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%dtlimit,label="dtlimit"//mystrm//':', rc=rc) @@ -674,21 +690,24 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%meshfile,label="stream_mesh_file"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_mesh_file must be provided") + call shr_log_error("stream_mesh_file must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="stream_vectors"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%stream_vectors,label="stream_vectors"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_vectors must be provided") + call shr_log_error("stream_vectors must be provided", rc=rc) + return endif if( ESMF_ConfigGetLen(config=CF, label="stream_lev_dimname"//mystrm//':', rc=rc) > 0 ) then call ESMF_ConfigGetAttribute(CF,value=streamdat(i)%lev_dimname,label="stream_lev_dimname"//mystrm//':', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else - call shr_sys_abort("stream_lev_dimname must be provided") + call shr_log_error("stream_lev_dimname must be provided", rc=rc) + return endif ! Get a list of stream file names @@ -703,7 +722,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, enddo deallocate(strm_tmpstrings) else - call shr_sys_abort("stream data files must be provided") + call shr_log_error("stream data files must be provided", rc=rc) + return endif ! Get name of stream variables in file and model @@ -718,7 +738,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, enddo deallocate(strm_tmpstrings) else - call shr_sys_abort("stream data variables must be provided") + call shr_log_error("stream data variables must be provided", rc=rc) + return endif ! Initialize stream pio @@ -739,7 +760,8 @@ subroutine shr_stream_init_from_esmfconfig(streamfilename, streamdat, logunit, ! Error check if (trim(streamdat(i)%taxmode) == shr_stream_taxis_extend .and. streamdat(i)%dtlimit < 1.e10) then - call shr_sys_abort(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30") + call shr_log_error(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30", rc=rc) + return end if enddo ! end loop nstrm @@ -826,7 +848,6 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & cycle = .false. limit = .true. else - write(strm%logunit,*) trim(subName),' ERROR: illegal taxMode = ',trim(strm%taxMode) call shr_sys_abort(trim(subName)//' ERROR: illegal taxMode = '//trim(strm%taxMode)) endif @@ -886,7 +907,6 @@ subroutine shr_stream_findBounds(strm, mDateIn, secIn, isroot_task, & end do end do A if (.not. strm%found_lvd) then - write(strm%logunit,F00) "ERROR: LVD not found, all data is before yearFirst" call shr_sys_abort(trim(subName)//" ERROR: LVD not found, all data is before yearFirst") else !--- LVD is in or beyond yearFirst, verify it is not beyond yearLast --- @@ -1235,6 +1255,7 @@ subroutine shr_stream_readTCoord(strm, k, isroot_task, rc) integer :: old_handle ! previous setting of pio error handling real(R8) :: nsec ! elapsed secs on calendar date real(R8),allocatable :: tvar(:) + character(CX) :: msg character(*),parameter :: subname = '(shr_stream_readTCoord) ' !------------------------------------------------------------------------------- @@ -1314,9 +1335,9 @@ subroutine shr_stream_readTCoord(strm, k, isroot_task, rc) ! if offset is not zero, adjust strm%file(k)%date(n) and strm%file(k)%secs(n) if (strm%offset /= 0) then if (size(strm%file(k)%date) /= size(strm%file(k)%secs)) then - write(strm%logunit,'(a,2i7)') trim(subname)//" Incompatable date and secs sizes",& + write(msg ,'(a,2i7)') trim(subname)//" Incompatable date and secs sizes",& size(strm%file(k)%date), size(strm%file(k)%secs) - call shr_sys_abort() + call shr_sys_abort(trim(msg)) endif num = size(strm%file(k)%date) offin = strm%offset diff --git a/streams/dshr_tinterp_mod.F90 b/streams/dshr_tinterp_mod.F90 index ef634d120..104bea65e 100644 --- a/streams/dshr_tinterp_mod.F90 +++ b/streams/dshr_tinterp_mod.F90 @@ -7,12 +7,12 @@ module dshr_tInterp_mod use ESMF , only : ESMF_Time, ESMF_TimeInterval, ESMF_TimeIntervalGet use ESMF , only : ESMF_SUCCESS, operator(<), operator(-), operator(>), operator(==) use shr_kind_mod , only : i8=>shr_kind_i8, r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl, shr_kind_in - use shr_sys_mod , only : shr_sys_abort + use shr_log_mod , only : shr_log_error use shr_cal_mod , only : shr_cal_timeSet, shr_cal_advDateInt, shr_cal_date2julian use shr_orb_mod , only : shr_orb_cosz, shr_orb_decl, SHR_ORB_UNDEF_REAL use shr_const_mod , only : SHR_CONST_PI use dshr_methods_mod , only : chkerr - + use shr_sys_mod , only : shr_sys_abort implicit none private ! except @@ -88,7 +88,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg ! --- always check that 1 <= 2, although we could relax this requirement --- if (itime2 < itime1) then write(logunit,F01) ' ERROR: itime2 < itime1 D=',D1,S1,D2,S2 - call shr_sys_abort(subName//' itime2 < itime1 ') + call shr_log_error(subName//' itime2 < itime1 ', rc=rc) + return endif f1 = -1.0 @@ -121,7 +122,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg !--- check that itimein is between itime1 and itime2 --- if (itime2 < itimein .or. itime1 > itimein) then write(logunit,F02) ' ERROR illegal linear times: ',D1,S1,Din,Sin,D2,S2 - call shr_sys_abort(subName//' illegal itimes ') + call shr_log_error(subName//' illegal itimes ', rc=rc) + return endif if (itime2 == itime1) then f1 = 0.5_r8 @@ -135,8 +137,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg f1 = real(snum,r8)/real(sden,r8) endif else - if (debug > 0) write(logunit,F00) 'ERROR: illegal lalgo option: ',trim(lalgo) - call shr_sys_abort(subName//' illegal algo option '//trim(lalgo)) + call shr_log_error(subName//' illegal algo option '//trim(lalgo), rc=rc) + return endif f2 = c1 - f1 @@ -145,8 +147,8 @@ subroutine shr_tInterp_getFactors(D1,S1,D2,S2,Din,Sin,f1,f2,calendar,logunit,alg if (f1 < c0-eps .or. f1 > c1+eps .or. & f2 < c0-eps .or. f2 > c1+eps .or. & abs(f1+f2-c1) > eps) then - if (debug > 0) write(logunit,F01) 'ERROR: illegal tInterp values ',f1,f2 - call shr_sys_abort(subName//' illegal tInterp values ') + call shr_log_error(subName//' illegal tInterp values ', rc=rc) + return endif if (debug > 0) then @@ -204,9 +206,11 @@ subroutine shr_tInterp_getAvgCosz(tavCosz, lon, lat, & ! error checks if (eccen == SHR_ORB_UNDEF_REAL) then - call shr_sys_abort(subname//' ERROR in orb params for coszen tinterp') + call shr_log_error(subname//' ERROR in orb params for coszen tinterp', rc=rc) + return else if (modeldt < 1) then - call shr_sys_abort(subname//' ERROR: model dt < 1 for coszen tinterp') + call shr_log_error(subname//' ERROR: model dt < 1 for coszen tinterp', rc=rc) + return endif !------------------------------------------------------------------------------- @@ -216,7 +220,10 @@ subroutine shr_tInterp_getAvgCosz(tavCosz, lon, lat, & !--- get LB & UB dates --- call shr_cal_timeSet(reday1,ymd1,tod1,calendar) call shr_cal_timeSet(reday2,ymd2,tod2,calendar) - if (reday1 > reday2) call shr_sys_abort(subname//'ERROR: lower-bound > upper-bound') + if (reday1 > reday2) then + call shr_log_error(subname//'ERROR: lower-bound > upper-bound', rc=rc) + return + endif timeint = reday2-reday1 call ESMF_TimeIntervalGet(timeint, s_i8=dtsec, rc=rc) @@ -299,7 +306,7 @@ subroutine shr_tInterp_getCosz(cosz, lon, lat, ymd, tod, & lsize = size(lon) if (lsize < 1 .or. size(lat) /= lsize .or. size(cosz) /= lsize) then write(6,*)'ERROR: lsize,size(lat),size(cosz) = ',lsize,size(lat),size(cosz) - call shr_sys_abort(subname//' ERROR: lon lat cosz sizes disagree') + call shr_sys_abort(subname//' ERROR: lon lat cosz sizes disagree', file=__FILE__,line=__LINE__) endif call shr_cal_date2julian(ymd, tod, calday, calendar)