Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Made the following basalstress parameters namelist items in dynamics_nml: k2, alphab, threshold_bw.

* Updated documentation for updated basalstress parameters

* Correct typo in user_guide/ug_case)settings.rst

* Modified ice_read_write.F90:ice_open. Added nbytes variable to allow for large grids that can cause integer overflow

* Modified ice_read_write.F90:ice_open. Added nbytes variable to allow for large grids that can cause integer overflow

* Revert "Correct typo in user_guide/ug_case)settings.rst"

Reverting to make new branch to commit code changes, instead of working off of master.

This reverts commit 06c614a.

* Correct typo in ug_case_settings.rst

* Reverting to version prior to updating ice_open

* retrigger checks

* In ice_open and ice_open_ext, made grid variables 8 byte integers. This is to allow for large grids (Like GOFS) that have integer overflow with 4 byte integers

* Implement nbytes to determine record lengts for ice_open. This helps with large grids thta might cause integer overflow when using nbits

* Minor comment update in ice_read_write.F90

* Moved bits_per_byte to module level parameters
  • Loading branch information
daveh150 authored Feb 28, 2020
1 parent e81f710 commit abc7b5a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cicecore/cicedynB/infrastructure/ice_read_write.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ module ice_read_write
implicit none

private

integer (kind=int_kind), parameter, private :: &
bits_per_byte = 8 ! number of bits per byte.
! used to determine RecSize in ice_open

public :: ice_open, &
ice_open_ext, &
ice_open_nc, &
Expand Down Expand Up @@ -86,7 +91,7 @@ subroutine ice_open(nu, filename, nbits, algn)
nbits ! no. of bits per variable (0 for sequential access)

integer (kind=int_kind), intent(in), optional :: algn
integer (kind=int_kind) :: RecSize, Remnant
integer (kind=int_kind) :: RecSize, Remnant, nbytes

character (*) :: filename

Expand All @@ -99,7 +104,13 @@ subroutine ice_open(nu, filename, nbits, algn)
open(nu,file=filename,form='unformatted')

else ! direct access
RecSize = nx_global*ny_global*nbits/8

! use nbytes to compute RecSize.
! this prevents integer overflow with large global grids using nbits
! nx*ny*nbits > 2^31 -1 (i.e., global grid 9000x7054x64)
nbytes = nbits/bits_per_byte
RecSize = nx_global*ny_global*nbytes

if (present(algn)) then
! If data is keept in blocks using given sizes (=algn)
! Used in eg. HYCOM binary files, which are stored as "blocks" dividable by 16384 bit (=algn)
Expand Down Expand Up @@ -131,6 +142,8 @@ subroutine ice_open_ext(nu, filename, nbits)
integer (kind=int_kind), intent(in) :: &
nu , & ! unit number
nbits ! no. of bits per variable (0 for sequential access)

integer (kind=int_kind) :: RecSize, nbytes

character (*) :: filename

Expand All @@ -150,7 +163,12 @@ subroutine ice_open_ext(nu, filename, nbits)
nx = nx_global + 2*nghost
ny = ny_global + 2*nghost

open(nu,file=filename,recl=nx*ny*nbits/8, &
! use nbytes to compute RecSize.
! this prevents integer overflow with large global grids using nbits
! nx*ny*nbits > 2^31 -1 (i.e., global grid 9000x7054x64)
nbytes = nbits/bits_per_byte
RecSize = nx*ny*nbytes
open(nu,file=filename,recl=RecSize, &
form='unformatted',access='direct')
endif ! nbits = 0

Expand Down

0 comments on commit abc7b5a

Please sign in to comment.