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

Main namelist debug #671

Merged
merged 5 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
21 changes: 19 additions & 2 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ subroutine init_hist (dt)
integer (kind=int_kind), dimension(max_nstrm) :: &
ntmp
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
character(len=char_len_long) :: tmpstr2 ! for namelist errors

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

!-----------------------------------------------------------------
Expand Down Expand Up @@ -131,15 +133,30 @@ subroutine init_hist (dt)
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)
!if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif

endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_nml')
call abort_ice(subname//'ERROR: reading icefields_nml: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

! histfreq options ('1','h','d','m','y')
Expand Down
22 changes: 19 additions & 3 deletions cicecore/cicedynB/analysis/ice_history_bgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ subroutine init_hist_bgc_2D
tr_bgc_N, tr_bgc_C, tr_bgc_chl, &
tr_bgc_DON, tr_bgc_Fe, tr_bgc_hum, &
skl_bgc, solve_zsal, z_tracers
character(len=*), parameter :: subname = '(init_hist_bgc_2D)'

character(len=char_len_long) :: tmpstr2 ! for namelist errors
character(len=*), parameter :: subname = '(init_hist_bgc_2D)'

call icepack_query_parameters(skl_bgc_out=skl_bgc, &
solve_zsal_out=solve_zsal, z_tracers_out=z_tracers)
Expand Down Expand Up @@ -313,15 +315,29 @@ subroutine init_hist_bgc_2D
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_bgc_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif

endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_bgc_nml')
call abort_ice(subname//'ERROR: reading icefields_bgc_nml: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

if (.not. tr_iso) then
Expand Down
22 changes: 19 additions & 3 deletions cicecore/cicedynB/analysis/ice_history_drag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ subroutine init_hist_drag_2D
integer (kind=int_kind) :: ns
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
logical (kind=log_kind) :: formdrag
character(len=char_len_long) :: tmpstr2 ! for namelist errors

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

call icepack_query_parameters(formdrag_out=formdrag)
Expand All @@ -89,16 +91,30 @@ subroutine init_hist_drag_2D
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_drag_nml,iostat=nml_error)
if (nml_error > 0) read(nu_nml,*) ! for Nagware compiler
! if (nml_error > 0) read(nu_nml,*) ! for Nagware compiler
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif

endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_drag_nml')
call abort_ice(subname//'ERROR: reading icefields_drag_nml: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

call broadcast_scalar (f_Cdn_atm, master_task)
Expand Down
19 changes: 17 additions & 2 deletions cicecore/cicedynB/analysis/ice_history_fsd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ subroutine init_hist_fsd_2D
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
real (kind=dbl_kind) :: secday
logical (kind=log_kind) :: tr_fsd, wave_spec
character(len=char_len_long) :: tmpstr2 ! for namelist errors

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

call icepack_query_tracer_flags(tr_fsd_out=tr_fsd)
Expand All @@ -105,15 +107,28 @@ subroutine init_hist_fsd_2D
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_fsd_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif
endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_fsd_nml')
call abort_ice(subname//'ERROR: reading icefields_fsd_nml: '// &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

call broadcast_scalar (f_afsd, master_task)
Expand Down
21 changes: 19 additions & 2 deletions cicecore/cicedynB/analysis/ice_history_mechred.F90
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ subroutine init_hist_mechred_2D
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
real (kind=dbl_kind) :: secday
logical (kind=log_kind) :: tr_lvl
character(len=char_len_long) :: tmpstr2 ! for namelist errors

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

call icepack_query_parameters(secday_out=secday)
Expand All @@ -111,15 +113,30 @@ subroutine init_hist_mechred_2D
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_mechred_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif


endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_mechred_nml')
call abort_ice(subname//'ERROR: reading icefields_mechred_nml: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

if (.not. tr_lvl) then
Expand Down
21 changes: 19 additions & 2 deletions cicecore/cicedynB/analysis/ice_history_pond.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ subroutine init_hist_pond_2D
integer (kind=int_kind) :: ns
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
logical (kind=log_kind) :: tr_pond
character(len=char_len_long) :: tmpstr2 ! for namelist errors

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

call icepack_query_tracer_flags(tr_pond_out=tr_pond)
Expand All @@ -94,15 +96,30 @@ subroutine init_hist_pond_2D
endif
do while (nml_error > 0)
read(nu_nml, nml=icefields_pond_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)

! check if there was an error.
! Write out errorneous line.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif


endif
call release_fileunit(nu_nml)

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
close (nu_nml)
call abort_ice(subname//'ERROR: reading icefields_pond_nml')
call abort_ice(subname//'ERROR: reading icefields_pond_nml: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif

if (.not. tr_pond) then
Expand Down
66 changes: 43 additions & 23 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -563,39 +563,59 @@ subroutine input_data

do while (nml_error > 0)
print*,'Reading setup_nml'
read(nu_nml, nml=setup_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=setup_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading grid_nml'
read(nu_nml, nml=grid_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=grid_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading tracer_nml'
read(nu_nml, nml=tracer_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=tracer_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading thermo_nml'
read(nu_nml, nml=thermo_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=thermo_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading dynamics_nml'
read(nu_nml, nml=dynamics_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=dynamics_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading shortwave_nml'
read(nu_nml, nml=shortwave_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=shortwave_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading ponds_nml'
read(nu_nml, nml=ponds_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=ponds_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading snow_nml'
read(nu_nml, nml=snow_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=snow_nml,iostat=nml_error)
if (nml_error /= 0) exit

print*,'Reading forcing_nml'
read(nu_nml, nml=forcing_nml,iostat=nml_error)
if (nml_error /= 0) exit
end do
if (nml_error == 0) close(nu_nml)
endif
read(nu_nml, nml=forcing_nml,iostat=nml_error)
if (nml_error /= 0) exit

end do ! while nml_error > 0

! check if there was an error.
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif
endif ! if my_task == master_task

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: reading namelist', &
file=__FILE__, line=__LINE__)
call abort_ice(subname//'ERROR: reading namelist: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif
call release_fileunit(nu_nml)

Expand Down
16 changes: 14 additions & 2 deletions cicecore/shared/ice_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,7 @@ subroutine input_zbgc
nml_error, & ! namelist i/o error flag
abort_flag

character (len=char_len_long) :: tmpstr2
character(len=*), parameter :: subname='(input_zbgc)'

!-----------------------------------------------------------------
Expand Down Expand Up @@ -1314,12 +1315,23 @@ subroutine input_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) close(nu_nml)
if (nml_error == 0) then
close(nu_nml) ! no error. close file
else ! nml_error not zero
! backspace, re-read erroneous line, then print
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
endif
endif

call broadcast_scalar(nml_error, master_task)
call broadcast_scalar(tmpstr2, master_task)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: reading zbgc namelist')
call abort_ice(subname//'ERROR: reading zbgc namelist: ' // &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
endif
call release_fileunit(nu_nml)

Expand Down