Bug in initialization of Tobc_in and Tobc_out

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Bug in initialization of Tobc_in and Tobc_out

#1 Unread post by m.hadfield »

In ROMS 2.1, arrays Tobc_in and Tobc_out are allocated in subroutine initialize_scalars (mod_scalars.F lines 1263-1264) and written to netCDF output files in function wrt_info (wrt_info.F lines 608-632). They are given values in subroutine set_nudgcof_tile (set_nudgcof.F lines 552-665) but only for the boundaries on which the corresponding xxxx_TNUDGING option is defined. So there may be uninitialised values written to the output file. This can generates an error; whether this actually happens depends on how the compiler treats allocated, but uninitialised, variables and on how tolerant the netCDF library is.

One solution is to write Tobc_in and Tobc_out only for those boundaries where they are used. But this would be awkward, as each array is currently written to a single netCDF variable. The simpler solution is to initialise these arrays with zeros in initialize_scalars, eg. replace lines 1263-1264 in mod_scalars.F

Code: Select all

      allocate ( Tobc_in(MT,Ngrids,4) )
      allocate ( Tobc_out(MT,Ngrids,4) )
with

Code: Select all

      allocate ( Tobc_in(MT,Ngrids,4) )
      Tobc_in = IniVal
      allocate ( Tobc_out(MT,Ngrids,4) )
      Tobc_out = IniVal

User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

#2 Unread post by arango »

Yes, this is a good solution.

Thank you, H

Post Reply