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

Update namelist implementation #382

Merged
merged 1 commit into from
Dec 24, 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
165 changes: 77 additions & 88 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ 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 @@ -294,143 +293,133 @@ subroutine input_data
! read from input file
!-----------------------------------------------------------------

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
write(ice_stdout,*) 'error opening namelist file '//trim(nml_filename)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
call icedrv_system_abort(string=subname//'ERROR: open file '// &
trim(nml_filename), &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

print*,'Reading namelist file ',nml_filename

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading setup_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: setup_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: setup_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading grid_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: grid_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: grid_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading thermo_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: thermo_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
print*,'Reading tracer_nml'
do while (nml_error > 0)
read(nu_nml, nml=tracer_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=thermo_nml,iostat=nml_error)
end do
if (nml_error /= 0) then
! 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__)
call icedrv_system_abort(string=subname//'ERROR: thermo_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading tracer_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: tracer_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
print*,'Reading thermo_nml'
do while (nml_error > 0)
read(nu_nml, nml=thermo_nml,iostat=nml_error)
if (nml_error /= 0) exit
read(nu_nml, nml=tracer_nml,iostat=nml_error)
end do
if (nml_error /= 0) then
! 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__)
call icedrv_system_abort(string=subname//'ERROR: tracer_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading shortwave_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: shortwave_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: shortwave_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading ponds_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: ponds_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: ponds_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

if (tr_snow) then
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
nml_error = 1
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
! 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)
write(nu_diag,*) subname,' Reading snow_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: snow_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
do while (nml_error > 0)
read(nu_nml, nml=snow_nml,iostat=nml_error)
end do
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: snow_nml reading ', &
file=__FILE__, line=__LINE__)
endif

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
write(nu_diag,*) subname,' Reading forcing_nml'
rewind(unit=nu_nml, iostat=nml_error)
if (nml_error /= 0) then
call icedrv_system_abort(string=subname//'ERROR: forcing_nml rewind ', &
file=__FILE__, line=__LINE__)
endif
nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: forcing_nml reading ', &
file=__FILE__, line=__LINE__)
endif

close(nu_nml)

!-----------------------------------------------------------------
Expand Down
21 changes: 8 additions & 13 deletions configuration/driver/icedrv_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,6 @@ 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 @@ -1008,25 +1006,22 @@ subroutine init_zbgc
! read from input file
!-----------------------------------------------------------------

write(nu_diag,*) subname,' Reading zbgc_nml'

open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
print*,'error opening zbgc namelist file '//trim(nml_filename)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
call icedrv_system_abort(string=subname//'ERROR: zbgc_nml open file '// &
trim(nml_filename), &
file=__FILE__, line=__LINE__)
endif

nml_error = 1
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
! 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__)
call icedrv_system_abort(string=subname//'ERROR: zbgc_nml reading ', &
file=__FILE__, line=__LINE__)
endif
close(nu_nml)

Expand Down