! bn_append_dsg.jnl
!From SOCAT 3: appending to a dsg file where the new variable is on the obs
! dimension. THe file has no coordinate variable, and we want to keep it that way.
! Ferret needs to detect the dimension-only axis and keep it as-is. Do not upcase,
! do not write a coordinate variable.
!
! Contains the metadata variables, global attributes, and incoming variables.
! Where we recompute some of the incoming variables and append them to the file,
! the values in the file are replaced. 
!
!  Argument is a file name; the single-cruise dsg file from the data entry
! 
! We append more variables to the file, using the same obs dimension.
! NOTE With the fix for ticket 2241, we need to add CANCEL MODE UPCASE.

sp rm test_save_dsg.nc 
sp cp test_save_dsg_in.nc test_save_dsg.nc 

use test_save_dsg.nc

cancel mode upcase

! Lon in 0-360
let/title="longitude"/units="degrees_east" lon360 = IF longitude LT 0 THEN longitude+360 else longitude
define attribute/output lon360.ioos_category = "Location"
define attribute/output lon360.standard_name = "Longitude"
define attribute/output lon360.history = "added to test_save_dsg.nc"

save/quiet/append/file=test_save_dsg.nc lon360 

! The longitude and lon360 variables should have the same lowercase (obs) dimension.

sp ncdump -h test_save_dsg.nc

set mode/last upcase

