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

Fix minor issues found during testing #1

Merged
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
39 changes: 27 additions & 12 deletions columnphysics/icepack_parameters.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1013,15 +1013,20 @@ subroutine icepack_init_parameters( &

! check array sizes and re/allocate if necessary
if (present(snowage_tau_in) ) then
if (size(snowage_tau_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_tau_in,dim=1) /= isnw_rhos .or. &
size(snowage_tau_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_tau_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_tau)) then
allocate(snowage_tau(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_tau(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_tau = snowage_tau_in
elseif (size(snowage_tau) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_tau,dim=1) /= isnw_rhos .or. &
size(snowage_tau,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau,dim=3) /= isnw_T ) then
deallocate(snowage_tau)
allocate(snowage_tau(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_tau(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_tau = snowage_tau_in
else
snowage_tau = snowage_tau_in
Expand All @@ -1030,15 +1035,20 @@ subroutine icepack_init_parameters( &

! check array sizes and re/allocate if necessary
if (present(snowage_kappa_in) ) then
if (size(snowage_kappa_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_kappa_in,dim=1) /= isnw_rhos .or. &
size(snowage_kappa_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_kappa_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_kappa)) then
allocate(snowage_kappa(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_kappa = snowage_kappa_in
elseif (size(snowage_kappa) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_kappa,dim=1) /= isnw_rhos .or. &
size(snowage_kappa,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa,dim=3) /= isnw_T ) then
deallocate(snowage_kappa)
allocate(snowage_kappa(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_kappa = snowage_kappa_in
else
snowage_kappa = snowage_kappa_in
Expand All @@ -1047,15 +1057,20 @@ subroutine icepack_init_parameters( &

! check array sizes and re/allocate if necessary
if (present(snowage_drdt0_in) ) then
if (size(snowage_drdt0_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_drdt0_in,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_drdt0_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_drdt0)) then
allocate(snowage_drdt0(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_drdt0 = snowage_drdt0_in
elseif (size(snowage_drdt0) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_drdt0,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0,dim=3) /= isnw_T ) then
deallocate(snowage_drdt0)
allocate(snowage_drdt0(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_drdt0 = snowage_drdt0_in
else
snowage_drdt0 = snowage_drdt0_in
Expand Down
49 changes: 46 additions & 3 deletions columnphysics/icepack_snow.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,46 @@ subroutine icepack_init_snow
min_T = 223.15_dbl_kind
del_T = 5.0_dbl_kind
lin_T = .true.
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
! check if these are already allocated/set, if so, make sure size is OK
if (allocated(snowage_tau)) then
if (size(snowage_tau,dim=1) /= isnw_rhos .or. &
size(snowage_tau,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_tau size snw_aging_table=snicar')
return
endif
else
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_kappa)) then
if (size(snowage_kappa,dim=1) /= isnw_rhos .or. &
size(snowage_kappa,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_kappa size snw_aging_table=snicar')
return
endif
else
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_drdt0)) then
if (size(snowage_drdt0,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_drdt0 size snw_aging_table=snicar')
return
endif
else
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_rhos)) deallocate(snowage_rhos)
if (allocated(snowage_Tgrd)) deallocate(snowage_Tgrd)
if (allocated(snowage_T)) deallocate(snowage_T)
allocate (snowage_rhos (isnw_rhos))
allocate (snowage_Tgrd (isnw_Tgrd))
allocate (snowage_T (isnw_T))
Expand Down Expand Up @@ -137,6 +174,12 @@ subroutine icepack_init_snow
min_T = 243.15_dbl_kind
del_T = 5.0_dbl_kind
lin_T = .true.
if (allocated(snowage_tau)) deallocate(snowage_tau)
if (allocated(snowage_kappa)) deallocate(snowage_kappa)
if (allocated(snowage_drdt0)) deallocate(snowage_drdt0)
if (allocated(snowage_rhos)) deallocate(snowage_rhos)
if (allocated(snowage_Tgrd)) deallocate(snowage_Tgrd)
if (allocated(snowage_T)) deallocate(snowage_T)
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
Expand Down
2 changes: 1 addition & 1 deletion columnphysics/icepack_therm_vertical.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ subroutine thickness_changes (nilyr, nslyr, &
qsub = zqsn(k) - rhos*Lvap ! qsub < 0
dhs = max (-dzs(k), esub/qsub) ! esub > 0, dhs < 0

mass = massice(1) + massliq(1)
mass = massice(k) + massliq(k)
massi = c0
if (dzs(k) > puny) massi = c1 + dhs/dzs(k)
massice(k) = massice(k) * massi
Expand Down
21 changes: 15 additions & 6 deletions configuration/driver/icedrv_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,9 @@ subroutine input_data
restart_dir = './' ! write to executable dir for default
restart_file = 'iced' ! restart file name prefix
restart_format = 'bin' ! default restart format is binary, other option 'nc'
! for NetCDF
history_format = '' ! if 'nc', write history files. Otherwise do nothing
ice_ic = 'default' ! initial conditions are specified in the code
! otherwise, the filename for reading restarts
history_format = 'none' ! if 'nc', write history files. Otherwise do nothing
ice_ic = 'default' ! initial conditions are specified in the code
! otherwise, the filename for reading restarts
ndtd = 1 ! dynamic time steps per thermodynamic time step
l_mpond_fresh = .false. ! logical switch for including meltpond freshwater
! flux feedback to ocean model
Expand Down Expand Up @@ -547,6 +546,16 @@ subroutine input_data
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif

if (restart_format /= 'bin' .and. restart_format /= 'nc') then
write (nu_diag,*) 'WARNING: restart_format value unknown '//trim(restart_format)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif

if (history_format /= 'none' .and. history_format /= 'nc') then
write (nu_diag,*) 'WARNING: history_format value unknown '//trim(history_format)
call icedrv_system_abort(file=__FILE__,line=__LINE__)
endif

if (tr_aero .and. trim(shortwave) /= 'dEdd') then
write (nu_diag,*) 'WARNING: aerosols activated but dEdd'
write (nu_diag,*) 'WARNING: shortwave is not.'
Expand Down Expand Up @@ -648,9 +657,9 @@ subroutine input_data
trim(restart_dir)
write(nu_diag,*) ' restart_file = ', &
trim(restart_file)
write(nu_diag,*) ' restart_format = ', &
write(nu_diag,1030) ' restart_format = ', &
trim(restart_format)
write(nu_diag,1010) ' history_format = ', trim(history_format)
write(nu_diag,1030) ' history_format = ', trim(history_format)
write(nu_diag,*) ' ice_ic = ', &
trim(ice_ic)
write(nu_diag,1010) ' conserv_check = ', conserv_check
Expand Down
30 changes: 10 additions & 20 deletions configuration/driver/icedrv_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ subroutine dumpfile
tr_pond_topo, tr_pond_lvl, tr_snow, tr_fsd
! solve_zsal, skl_bgc, z_tracers

integer (kind=int_kind), allocatable :: dims(:),dims1(:)
integer (kind=int_kind) :: dims(2)

character(len=char_len_long) :: filename
character(len=*), parameter :: subname='(dumpfile)'
Expand Down Expand Up @@ -124,6 +124,7 @@ subroutine dumpfile
if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
file=__FILE__,line= __LINE__)

dims(:) = 0
if (restart_format == 'bin') then
write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') &
restart_dir(1:lenstr(restart_dir)), &
Expand Down Expand Up @@ -161,7 +162,6 @@ subroutine dumpfile
status = nf90_def_dim(ncid,'ncat',ncat,dimid_ncat)

! Get dimension IDs
allocate(dims(2))
dims(1) = dimid_ni
dims(2) = dimid_ncat
#else
Expand Down Expand Up @@ -1274,8 +1274,7 @@ subroutine write_restart_field_nc2D(ncid,nrec,work,atype,vname,ndim3,diag)
ncid , & ! unit number
ndim3 , & ! third dimension
nrec ! record number (0 for sequential access)
real (kind=dbl_kind), dimension(nx,ncat), &
intent(in) :: &
real (kind=dbl_kind), intent(in), dimension(nx,ncat) :: &
work ! input array (real, 8-byte)
character (len=4), intent(in) :: &
atype ! format for output array
Expand Down Expand Up @@ -1311,8 +1310,7 @@ subroutine write_restart_field_nc1D(ncid,nrec,work,atype,vname,ndim3,diag)
ncid , & ! unit number
ndim3 , & ! third dimension
nrec ! record number (0 for sequential access)
real (kind=dbl_kind), dimension(nx), &
intent(in) :: &
real (kind=dbl_kind), intent(in), dimension(nx) :: &
work ! input array (real, 8-byte)
character (len=4), intent(in) :: &
atype ! format for output array
Expand Down Expand Up @@ -1359,8 +1357,7 @@ subroutine ice_write_nc2D(fid, nrec, varid, work, diag)
logical (kind=log_kind), intent(in) :: &
diag ! if true, write diagnostic output

real (kind=dbl_kind), dimension(nx,ncat), &
intent(in) :: &
real (kind=dbl_kind), intent(in), dimension(nx,ncat) :: &
work ! output array (real, 8-byte)

! local variables
Expand Down Expand Up @@ -1420,8 +1417,7 @@ subroutine ice_write_nc1D(fid, nrec, varid, work, diag)
logical (kind=log_kind), intent(in) :: &
diag ! if true, write diagnostic output

real (kind=dbl_kind), dimension(nx), &
intent(in) :: &
real (kind=dbl_kind), intent(in), dimension(nx) :: &
work ! output array (real, 8-byte)

! local variables
Expand Down Expand Up @@ -1476,11 +1472,9 @@ subroutine read_restart_field_net2D(nu,nrec,work,vname,ndim3, &
ndim3 , & ! third dimension
nrec ! record number (0 for sequential access)

real (kind=dbl_kind), dimension(nx,ncat), &
intent(inout) :: &
real (kind=dbl_kind), intent(inout), dimension(nx,ncat) :: &
work ! input array (real, 8-byte)


logical (kind=log_kind), intent(in) :: &
diag ! if true, write diagnostic output

Expand Down Expand Up @@ -1509,11 +1503,9 @@ subroutine read_restart_field_net1D(nu,nrec,work,vname,ndim3, &
ndim3 , & ! third dimension
nrec ! record number (0 for sequential access)

real (kind=dbl_kind), dimension(nx), &
intent(inout) :: &
real (kind=dbl_kind), intent(inout), dimension(nx) :: &
work ! input array (real, 8-byte)


logical (kind=log_kind), intent(in) :: &
diag ! if true, write diagnostic output

Expand Down Expand Up @@ -1546,8 +1538,7 @@ subroutine ice_read_nc2D(fid, nrec, varname, work, diag)
character (len=*), intent(in) :: &
varname ! field name in netcdf file

real (kind=dbl_kind), dimension(nx,ncat), &
intent(out) :: &
real (kind=dbl_kind), intent(out), dimension(nx,ncat) :: &
work ! output array (real, 8-byte)

integer (kind=int_kind) :: &
Expand Down Expand Up @@ -1610,8 +1601,7 @@ subroutine ice_read_nc1D(fid, nrec, varname, work, diag)
character (len=*), intent(in) :: &
varname ! field name in netcdf file

real (kind=dbl_kind), dimension(nx), &
intent(out) :: &
real (kind=dbl_kind), intent(out), dimension(nx) :: &
work ! output array (real, 8-byte)

integer (kind=int_kind) :: &
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/icepack_in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
dump_last = .false.
diagfreq = 24
diag_file = 'ice_diag'
history_format = ''
history_format = 'none'
cpl_bgc = .false.
conserv_check = .false.
/
Expand Down
3 changes: 2 additions & 1 deletion configuration/scripts/tests/io_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ smoke col 1x1 run1year,diag1,ionetcdf,histcdf
restart col 1x1 debug,ionetcdf,restcdf
smoke col 1x1 run1year,diag1,ionetcdf,restcdf
restart col 1x1 debug,ionetcdf,histcdf,restcdf
smoke col 1x1 run1year,diag1,ionetcdf,histcdf,restcdf
smoke col 1x1 run1year,diag1,ionetcdf,histcdf,restcdf

6 changes: 4 additions & 2 deletions doc/source/user_guide/ug_case_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ setup_nml
"", "``y``", "write restart every ``dumpfreq_n`` years", ""
"``dump_last``", "true/false", "write restart at end of run", "false"
"``dt``", "seconds", "thermodynamics time step length", "3600."
"``history_format``", "string", "provide netcdf history output if 'nc'", ""
"``history_format``", "``cdf``", "history file output in netcdf format", "``none``"
"","``none``","no history output",""
"``ice_ic``", "``default``", "latitude and sst dependent initial condition", "``default``"
"", "``none``", "no ice", ""
"", "'path/file'", "restart file name", ""
Expand All @@ -150,7 +151,8 @@ setup_nml
"``restart``", "logical", "initialize using restart file", "``.false.``"
"``restart_dir``", "string", "path to restart directory", "'./'"
"``restart_file``", "string", "output file prefix for restart dump", "'iced'"
"``restart_format``", "string", "history files are read/written in binary or netcdf format if set to 'bin' or 'nc' respectively", "'bin'"
"``restart_format``", "``bin``", "restart file output in binary format", "``bin``"
"","``cdf``","restart file output in netcdf format",""
"``use_leap_years``", "logical", "include leap days", "``.false.``"
"``year_init``", "integer", "the initial year if not using restart", "0"
"", "", "", ""
Expand Down