Opened 2 years ago

Closed 2 years ago

#915 closed bug (Fixed)

VERY IMPORTANT: corrected bug when defining depth arrays in output NetCDF files

Reported by: arango Owned by:
Priority: major Milestone: Release ROMS/TOMS 4.1
Component: Nonlinear Version: 4.0
Keywords: Cc:

Description

Corrected bug to define time-independent depth arrays in the output history, quicksave, and DA initialization NetCDF files. We get the following error during execution:

output statement overflows record, unit -5

The issue is fixed by changing the depth variable long_name attribute statement from:

        WRITE (Vinfo( 2),40) Vname(2,idpthR)

to

        WRITE (Vinfo( 2),40) TRIM(Vname(2,idpthR))
        ...

 40  FORMAT ('time independent',1x,a)

We need to use the intrinsic TRIM() function to remove the padding blanks and avoid overflow.

I am appalled about this one; no idea what the previous version of the compilers was doing here. Although the value in Vname for this case is "depth of RHO-points" the standard says that compilers should pad with blank spaces to the declared length of the character string (120). So, the first statement above prepended "time independent" to the resulting string, rendering the Vinfo(2) length larger than the declared 120 characters.

To avoid related issues in the future, the management of Vname and Vinfo is updated in several routines with a character length parameter, MaxLen in the delaration:

     integer, parameter :: MaxLen = 160    ! information string length
     ...
     character (len=MaxLen) :: Vname(6,0:NV)
     ...
     character (len=MaxLen), dimension(8) :: Vinfo

Notice its character length is incremented from 120 to 160.

Many thanks to Jiangtao Xu (NOAA) for reporting and tracking this bug.

Change History (1)

comment:1 by arango, 2 years ago

Resolution: Fixed
Status: newclosed
Note: See TracTickets for help on using tickets.