diff --git a/physics/GWD/cires_ugwp.F90 b/physics/GWD/cires_ugwp.F90 index beb7dbbc7..bcde8673f 100644 --- a/physics/GWD/cires_ugwp.F90 +++ b/physics/GWD/cires_ugwp.F90 @@ -89,7 +89,9 @@ subroutine cires_ugwp_init (me, master, nlunit, input_nml_file, logunit, & if (do_ugwp .or. cdmbgwd(3) > 0.0) then call cires_ugwpv0_mod_init (me, master, nlunit, input_nml_file, logunit, & fn_nml2, lonr, latr, levs, ak, bk, con_p0, dtp, & - cdmbgwd(1:2), cgwf, pa_rf_in, tau_rf_in) + cdmbgwd(1:2), cgwf, pa_rf_in, tau_rf_in, & + errmsg, errflg) + if (errflg/=0) return else write(errmsg,'(*(a))') "Logic error: cires_ugwp_init called but do_ugwp is false and cdmbgwd(3) <= 0" errflg = 1 diff --git a/physics/GWD/cires_ugwp_module.F90 b/physics/GWD/cires_ugwp_module.F90 index a454a5eae..f34b0a7fa 100644 --- a/physics/GWD/cires_ugwp_module.F90 +++ b/physics/GWD/cires_ugwp_module.F90 @@ -107,7 +107,7 @@ module cires_ugwpv0_module !>This subroutine initializes CIRES UGWP subroutine cires_ugwpv0_mod_init (me, master, nlunit, input_nml_file, logunit, & fn_nml, lonr, latr, levs, ak, bk, pref, dtp, cdmvgwd, cgwf, & - pa_rf_in, tau_rf_in) + pa_rf_in, tau_rf_in, errmsg, errflg) use ugwpv0_oro_init, only : init_oro_gws_v0 use ugwpv0_wmsdis_init, only : initsolv_wmsdis_v0, ilaunch @@ -129,7 +129,11 @@ subroutine cires_ugwpv0_mod_init (me, master, nlunit, input_nml_file, logunit, & real, intent (in) :: cdmvgwd(2), cgwf(2) ! "scaling" controls for "old" GFS-GW schemes real, intent (in) :: pa_rf_in, tau_rf_in + character(len=*), intent(inout) :: errmsg + integer, intent(inout) :: errflg + integer :: ios + character(len=256) :: msg logical :: exists real :: dxsg integer :: k @@ -142,10 +146,16 @@ subroutine cires_ugwpv0_mod_init (me, master, nlunit, input_nml_file, logunit, & inquire (file =trim (fn_nml) , exist = exists) if (.not. exists) then - if (me == master) & - write (6, *) 'separate ugwp :: namelist file: ', trim (fn_nml), ' does not exist' + write(errmsg,*) 'separate ugwp :: namelist file: ', trim (fn_nml), ' does not exist' + errflg = 1 + return else - open (unit = nlunit, file = trim(fn_nml), action = 'read', status = 'old', iostat = ios) + open (unit = nlunit, file = trim(fn_nml), action = 'read', status = 'old', iostat = ios, iomsg = msg) + if (ios /= 0) then + write(errmsg,*) 'ERROR: cannot open namelist file ', trim(fn_nml), ' iostat=', ios, ' msg="' // trim(msg) // '"' + errflg = 1 + return + endif endif rewind (nlunit) read (nlunit, nml = cires_ugwp_nml) diff --git a/physics/GWD/unified_ugwp.F90 b/physics/GWD/unified_ugwp.F90 index aeaa54471..2fbafff24 100644 --- a/physics/GWD/unified_ugwp.F90 +++ b/physics/GWD/unified_ugwp.F90 @@ -138,7 +138,9 @@ subroutine unified_ugwp_init (me, master, nlunit, input_nml_file, logunit, & if (cdmbgwd(3) > 0.0) then call cires_ugwpv0_mod_init(me, master, nlunit, input_nml_file, logunit, & fn_nml2, lonr, latr, levs, ak, bk, con_p0, dtp, & - cdmbgwd(1:2), cgwf, pa_rf_in, tau_rf_in) + cdmbgwd(1:2), cgwf, pa_rf_in, tau_rf_in, & + errmsg, errflg) + if (errflg/=0) return else write(errmsg,'(*(a))') "Logic error: cires_ugwp_mod_init called but & &do_ugwp_v0 or do_ugwp_v0_nst_only is true and cdmbgwd(3) <= 0" diff --git a/physics/SFC_Models/Land/Noahmp/lnd_iau_mod.F90 b/physics/SFC_Models/Land/Noahmp/lnd_iau_mod.F90 index f82669a5d..cf32a8604 100644 --- a/physics/SFC_Models/Land/Noahmp/lnd_iau_mod.F90 +++ b/physics/SFC_Models/Land/Noahmp/lnd_iau_mod.F90 @@ -170,6 +170,9 @@ subroutine land_iau_mod_set_control(Land_IAU_Control,fn_nml,input_nml_file, me, write(iosstr, '(I0)') ios errmsg = 'lnd_iau_mod_set_control: I/O error code '//trim(iosstr)//' at land_iau namelist read' errflg = 1 +#ifndef INTERNAL_FILE_NML + close(nlunit) +#endif return end if @@ -179,6 +182,9 @@ subroutine land_iau_mod_set_control(Land_IAU_Control,fn_nml,input_nml_file, me, WRITE(6, * ) 'lnd_iau_mod_set_control: Warning! EoF ('//trim(iosstr)//') while reading land_iau namelist,' & // ' likely because land_iau_nml was not found in input.nml. It will be set to default.' endif +#ifndef INTERNAL_FILE_NML + close(nlunit) +#endif endif if (me == mpi_root) then