Skip to content

Commit

Permalink
update namelist reading to allow arbitrary order of namelist groups. …
Browse files Browse the repository at this point in the history
…Also fixes nag issue introduced recently and detected on izumi (#369)
  • Loading branch information
apcraig authored Aug 31, 2021
1 parent e1f3574 commit 0836bfc
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 28 deletions.
104 changes: 80 additions & 24 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -294,55 +294,111 @@ subroutine input_data

open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
if (nml_error /= 0) then
nml_error = -1
else
nml_error = 1
write(ice_stdout,*) 'error opening namelist file '//trim(nml_filename)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

do while (nml_error > 0)
print*,'Reading namelist file ',nml_filename
print*,'Reading namelist file ',nml_filename

print*,'Reading setup_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

print*,'Reading grid_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

print*,'Reading tracer_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

print*,'Reading thermo_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
end do
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

print*,'Reading shortwave_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

print*,'Reading ponds_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

if (tr_snow) then
print*,'Reading snow_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
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)
endif

print*,'Reading forcing_nml'
open (nu_nml, file=nml_filename, status='old',iostat=nml_error)
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) close(nu_nml)
if (nml_error /= 0) then
write(ice_stdout,*) 'error reading namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

!-----------------------------------------------------------------
! set up diagnostics output and resolve conflicts
!-----------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions configuration/driver/icedrv_init_column.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1008,20 +1008,20 @@ subroutine init_zbgc

open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
nml_error = -1
else
nml_error = 1
print*,'error opening zbgc namelist file '//trim(nml_filename)
call icedrv_system_abort(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)
end do
if (nml_error == 0) close(nu_nml)
if (nml_error /= 0) then
print*,'error reading zbgc namelist'
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif
close(nu_nml)

!-----------------------------------------------------------------
! resolve conflicts
Expand Down

0 comments on commit 0836bfc

Please sign in to comment.