W4DPSAS (netCDF) bug

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
jpm
Posts: 21
Joined: Thu Aug 27, 2009 4:37 pm
Location: UCSC

W4DPSAS (netCDF) bug

#1 Unread post by jpm »

There is a bug in the current version (820) of the W4DPSAS code. It appears to be relatively minor but may point to a bigger problem.

The error message I get is:
NETCDF_CLOSE - error while writing global attribute: bio_file
file: wc12_fwd_36524_001.nc
call from: w4dpsas_ocean.h, ROMS_run
The error occurs at the end of the first outer loop, while trying to close the associated fwd-file (the "001" fwd-file). I only get this error message because I use a biological model, I assume this message will not appear if no biological model is used.

Looking a bit deeper, the source of the error is code in w4dpsas_ocean.h which attempts to close the file associated with the the fwd-file netCDF ID (FWD(ng)%ncid):

Code: Select all

!
!  Close current forward NetCDF file.
!
        DO ng=1,Ngrids
          CALL netcdf_close (ng, iNLM, FWD(ng)%ncid)
          IF (exit_flag.ne.NoError) RETURN
        END DO
Initially, after the first call to main3d and outside of the outer loop, FWD(ng)%ncid is updated correctly:

Code: Select all

!
!  Set forward basic state NetCDF ID to nonlinear model trajectory to
!  avoid the inquiring stage.
!
      DO ng=1,Ngrids
        FWD(ng)%ncid=HIS(ng)%ncid
      END DO 
However, this update is missing after subsequent calls to main3d inside the outer loop. That is, FWD(ng)%ncid remains unchanged inside the outer loop and the next call to "netcdf_close (ng, iNLM, FWD(ng)%ncid)" triggers the error, as the netCDF ID stored in FWD(ng)%ncid has been closed already (and even been reused). While the failed writing of an attribute to the fwd-file is a relatively minor bug, I am wondering if the wrong value stored in FWD(ng)%ncid may have unwanted consequences in other parts of the code as well.

FIX: I have not done a lot of investigating on this but an additional update of FWD(ng)%ncid (see code above), right below the code closing the fwd-file (w4dpsas_ocean.h, line 1639) eliminates the error. I am not sure if there are unwanted consequences.
Jann Paul Mattern, Ocean Sciences Department, UCSC

Post Reply