[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20000320: NetCDF libraries vor Open VMS operating systems



Wiekie,

> To: Unidata Support <address@hidden>
> From: Wiekie Kollen <address@hidden>
> Subject: Re: 20000315: NetCDF libraries vor Open VMS operating systems 
> Organization: .
> Keywords: 200003201040.DAA26046

In the above message, you wrote:

> I have downloaded the VMS version of netCDF from
> ftp.unidata.ucar.edu/binary/vms-alpha several times.  When I try to
> use the backup program the file is giving following error messages.
> I think that the file is corrupt. Is there a mirror site I could
> download from?
> Any suggestions?
> 
> I could not find the NETcdf for Open VMS on  the mirror site ftp.dfd.dlr.de 

Regretably, our VMS support is essentially non-existent.

Downloading the BACKUP file via FTP causes the RMS information to be
lost.  As a consequence, BACKUP can't read the file.  You'll have to
restore the RMS attributes of the BACKUP file.

Angel Li was kind enough to send us the enclosed program that will do
just that.  You'll have to build and execute it on your VMS system.
According to Angel, the second argument is either 8192 or 32256.

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>

--------Begin header-file fatdef.h
# define fat$c_undefined        0
# define fat$c_fixed    1
# define fat$c_variable 2
# define fat$c_vfc      3
# define fat$c_stream   4
# define fat$c_streamlf 5
# define fat$c_streamcr 6
# define fat$c_sequential       0
# define fat$c_relative 1
# define fat$c_indexed  2
# define fat$c_direct   3
# define fat$m_fortrancc        1
# define fat$m_impliedcc        2
# define fat$m_printcc  4
# define fat$m_nospan   8
# define fat$k_length   32
# define fat$c_length   32
# define fat$s_fatdef   32

struct FAT {
        unsigned char   fat$b_rtype;
# define fat$s_rtype    4
# define fat$v_rtype    0
# define fat$s_fileorg  4
# define fat$v_fileorg  4
        unsigned char   fat$b_rattrib;
# define fat$v_fortrancc        0
# define fat$v_impliedcc        1
# define fat$v_printcc  2
# define fat$v_nospan   3
        unsigned short  fat$w_rsize;
/*      union {
                long            fat$l_hiblk;
            struct {    */
                unsigned short  fat$w_hiblkh;
                unsigned short  fat$w_hiblkl;
/*          };
        };      */
/*      union {
                long            fat$l_efblk;
            struct {    */
                unsigned short  fat$w_efblkh;
                unsigned short  fat$w_efblkl;
/*          };
        };      */
        short           fat$w_ffbyte;
        unsigned char   fat$b_bktsize;
        unsigned char   fat$b_vfcsize;
        unsigned short  fat$w_maxrec;
        unsigned short  fat$w_defext;
        unsigned short  fat$w_gbc;
        unsigned char   filler[8];
        unsigned short  fat$w_versions;
};
--------End header-file fatdef.h

--------Begin program fixrec.c
#include <stdio.h>      
#include <descrip.h>
#include <rms.h>
#include <ssdef.h>
#include <fibdef.h>
#include <iodef.h>
#include <atrdef.h>
#include <fchdef.h>
#include <fatdef.h>

struct IOSB {
  short iosb$w_value;
  short iosb$w_count;
  long  iosb$l_info;
};                  

struct acp_d {
  short acp$w_count;
  short acp$w_notused;
  long  acp$a_pointer;
};

static struct fibdef fib;
static struct acp_d fib_desc;

struct NAM nam_blk;
struct FAB fab_blk;
char exp_str[NAM$C_MAXRSS];
char res_str[NAM$C_MAXRSS];
struct dsc$descriptor_s res_str_d;
         
main (argc, argv)
    int argc;
    char **argv;
{
  long status;
  char dvi[NAM$C_DVI];
  struct dsc$descriptor_s dev_desc;
  struct atrdef atr[2];
  unsigned short chan = 0;
  struct IOSB iosb;
  struct FAT  fat;
  int nrecsize;

  if (argc < 3)
    {  
      fprintf (stderr, "Usage: fixrec filename recsize\n");
      exit (1);
    }

  nrecsize = atoi(argv[2]);
                
  nam_blk = cc$rms_nam;
  nam_blk.nam$l_rsa = res_str;
  nam_blk.nam$b_rss = NAM$C_MAXRSS;
  nam_blk.nam$l_esa = exp_str;
  nam_blk.nam$b_ess = NAM$C_MAXRSS;

  fab_blk = cc$rms_fab;
  fab_blk.fab$l_fop = FAB$M_NAM;
  fab_blk.fab$l_nam = &nam_blk;
  fab_blk.fab$l_fna = argv[1];

  res_str_d.dsc$w_length = NAM$C_MAXRSS;
  res_str_d.dsc$b_dtype  = DSC$K_DTYPE_T;
  res_str_d.dsc$b_class  = DSC$K_CLASS_S;
  res_str_d.dsc$a_pointer= res_str;
                      
  fab_blk.fab$b_fns = strlen(argv[1]);
  status = sys$parse(&fab_blk);
  if ((status & 0x1) != 1)
    exit (status);        

  status = sys$search(&fab_blk);
  if ((status & 0x1) != 1)
    {
      if (status == RMS$_NMF)
        exit(1);
      exit(status);
    }
  res_str_d.dsc$w_length = nam_blk.nam$b_rsl;
  status = lib$put_output(&res_str_d);
  if ((status & 0x1) != 1)
    exit(status);
      
  dev_desc.dsc$a_pointer = &(nam_blk.nam$t_dvi[1]);
  dev_desc.dsc$w_length = nam_blk.nam$t_dvi[0];
  dev_desc.dsc$b_dtype = DSC$K_DTYPE_T;
  dev_desc.dsc$b_class = DSC$K_CLASS_S;

  /*
   * Open channel to disk
   */
  status = sys$assign(&dev_desc, &chan, (long)0, (long)0);
  if (status != SS$_NORMAL)
    {
      fprintf (stderr, "Unable to assign disk\n");
      exit(status);
    }

  /*
   * Setup File Information Block
   */
  fib_desc.acp$a_pointer = &fib;
  fib_desc.acp$w_count   = 24;

  /*
   * Use File id and Directory id from NAM
   */
  fib.fib$r_fid_overlay.fib$w_fid[0] = nam_blk.nam$w_fid[0]; 
  fib.fib$r_fid_overlay.fib$w_fid[1] = nam_blk.nam$w_fid[1]; 
  fib.fib$r_fid_overlay.fib$w_fid[2] = nam_blk.nam$w_fid[2]; 
  fib.fib$r_did_overlay.fib$w_did[0] = nam_blk.nam$w_did[0]; 
  fib.fib$r_did_overlay.fib$w_did[1] = nam_blk.nam$w_did[1]; 
  fib.fib$r_did_overlay.fib$w_did[2] = nam_blk.nam$w_did[2]; 
  fib.fib$r_acctl_overlay.fib$l_acctl  = 0;
  fib.fib$r_nmctl_overlay.fib$w_nmctl  = FIB$M_FINDFID;

  /*
   * Read FAT
   */
  atr[0].atr$w_type = ATR$C_RECATTR;
  atr[0].atr$w_size = ATR$S_RECATTR;
  atr[0].atr$l_addr = &fat;
  atr[1].atr$w_size = 0;
  atr[1].atr$w_type = 0;

  status = sys$qiow((long)0, chan, (short)(IO$_ACCESS), &iosb,
                    (long)0, (long)0,
                    &fib_desc, (long)0, 0, 0,
                    atr, (long)0);
  if ((status != SS$_NORMAL) ||
      (iosb.iosb$w_value != SS$_NORMAL))
    {
      sys$dassgn (chan);
      fprintf (stderr, "Unable to access file: %d\n", status);
      exit(status);
    }
#ifdef notdef
  if (fat.fat$v_rtype != FAT$C_FIXED)
    {
      fprintf (stdout, "File record type must be FIXED\n");
      exit(1);
    }
#endif
  fprintf (stdout, "Current record size : %d\n", (int)fat.fat$w_rsize);
  fat.fat$w_rsize = nrecsize;
  fat.fat$b_rtype = fat$c_fixed | (fat$c_sequential<<4);
  fat.fat$b_rattrib = 0;
  fprintf (stdout, "New record size : %d\n", (int)fat.fat$w_rsize);

  status = sys$qiow((long)0, chan, (short)(IO$_MODIFY), &iosb,
                    (long)0, (long)0,
                    &fib_desc, (long)0, 0, 0,
                    atr, (long)0);
  if ((status != SS$_NORMAL) ||
      (iosb.iosb$w_value != SS$_NORMAL))
    {
      sys$dassgn (chan);
      fprintf (stderr, "Unable to modify file: %d\n", status);
      exit(status);
    }
}
--------End program fixrec.c