Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added method to check namelist errors #379

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ subroutine input_data

real (kind=real_kind) :: rpcesm, rplvl, rptopo
real (kind=dbl_kind) :: Cf, puny
character(len=char_len_long) :: tmpstr2 ! for namelist error

character(len=*), parameter :: subname='(input_data)'

!-----------------------------------------------------------------
Expand Down Expand Up @@ -306,9 +308,13 @@ subroutine input_data
print*,'Reading setup_nml'
do while (nml_error > 0)
read(nu_nml, nml=setup_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -318,9 +324,13 @@ subroutine input_data
print*,'Reading grid_nml'
do while (nml_error > 0)
read(nu_nml, nml=grid_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -330,9 +340,13 @@ subroutine input_data
print*,'Reading tracer_nml'
do while (nml_error > 0)
read(nu_nml, nml=tracer_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -342,9 +356,13 @@ subroutine input_data
print*,'Reading thermo_nml'
do while (nml_error > 0)
read(nu_nml, nml=thermo_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -354,9 +372,13 @@ subroutine input_data
print*,'Reading shortwave_nml'
do while (nml_error > 0)
read(nu_nml, nml=shortwave_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -366,9 +388,13 @@ subroutine input_data
print*,'Reading ponds_nml'
do while (nml_error > 0)
read(nu_nml, nml=ponds_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -379,9 +405,13 @@ subroutine input_data
print*,'Reading snow_nml'
do while (nml_error > 0)
read(nu_nml, nml=snow_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand All @@ -392,9 +422,13 @@ subroutine input_data
print*,'Reading forcing_nml'
do while (nml_error > 0)
read(nu_nml, nml=forcing_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
write(ice_stdout,*) 'ERROR: reading namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand Down
9 changes: 8 additions & 1 deletion configuration/driver/icedrv_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ subroutine init_zbgc
ntd , & ! for tracer dependency calculation
nk , & !
nt_depend

character(len=char_len_long) :: tmpstr2 ! for namelist errors

character(len=*), parameter :: subname='(init_zbgc)'

Expand Down Expand Up @@ -1016,9 +1018,14 @@ subroutine init_zbgc
print*,'Reading zbgc_nml'
do while (nml_error > 0)
read(nu_nml, nml=zbgc_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error /= 0) then
print*,'error reading zbgc namelist'
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2

print*,'ERROR: reading zbgc namelist ' // trim(tmpstr2)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
Expand Down