      program ncdtest

      INCLUDE 'netcdf.inc'
      
      PARAMETER (z = 45, y = 360, x = 40)
      REAL mione_N2(x, y,z)
      REAL mione_O(x, y, z)
      REAL mione_O2(x, y, z)
      REAL maglat(x)
      REAL mlt(y)
      REAL pressure(z)
      INTEGER level
      INTEGER NCID, STATUS      
      INTEGER NDIMS, NVARS, NGATTS, UNLIMDIMID
      CHARACTER*(NF_MAX_NAME) nameD1, nameD2, nameD3
      CHARACTER*(NF_MAX_NAME) nameV1, nameV2, nameV3, nameV4 
      CHARACTER*(NF_MAX_NAME) nameV5, nameV6, nameV7 
          
      INTEGER dim1ID, dim2ID, dim3ID
      INTEGER var1ID, var2ID, var3ID, var4ID, var5ID, var6ID, var7ID
      INTEGER size1, size2, size3
      INTEGER type1, type2, type3, type4, type5, type6, type7
      INTEGER nDIM1, nDIM2, nDIM3, nDIM4, nDIM5, nDIM6, nDIM7
      INTEGER nATT1, nATT2, nATT3, nATT4, nATT5, nATT6, nATT7
      INTEGER dims1ID(NF_MAX_VAR_DIMS), dims2ID(NF_MAX_VAR_DIMS)
      INTEGER dims3ID(NF_MAX_VAR_DIMS), dims4ID(NF_MAX_VAR_DIMS)
      INTEGER dims5ID(NF_MAX_VAR_DIMS), dims6ID(NF_MAX_VAR_DIMS), dims7ID(NF_MAX_VAR_DIMS)
      
            
      PRINT *, NF_INQ_LIBVERS()      
      STATUS = NF_OPEN('mione_gcm_level1.nc', 0, NCID)  
      IF (STATUS .NE. NF_NOERR) THEN
         PRINT *, NF_STRERROR(STATUS)      
      ELSE 
         write(6,*) ' ------------------------------ '        
         write(6,*) ' I have opened the ncdf for you ' 
         write(6,*) ' ------------------------------ '        
      ENDIF
      
      write(6,*) ' '
      write(6,*) ' Information about dim, var, att '
      write(6,*) ' ------------------------------- '
      STATUS = NF_INQ(NCID, NDIMS, NVARS, NGATTS, UNLIMDIMID)      
      write(6,*)      NDIMS, NVARS, NGATTS, UNLIMDIMID     
      
      write(6,*) '  '      
      write(6,*) ' Dimensions Ids '
      write(6,*) ' -------------- '
      STATUS = NF_INQ_DIMID(NCID, 'x', dim1ID)
      write(6,*)     dim1ID      
      STATUS = NF_INQ_DIMID(NCID, 'y', dim2ID)
      write(6,*)     dim2ID    
      STATUS = NF_INQ_DIMID(NCID, 'z', dim3ID)
      write(6,*)     dim3ID
      
      write(6,*) ' '
      write(6,*) ' Dimensions names and sizes '
      write(6,*) ' -------------------------- '
      STATUS = NF_INQ_DIM(NCID, 1, nameD1, size1)
      write(6,*)     nameD1, size1
      STATUS = NF_INQ_DIM(NCID, 2, nameD2, size2)
      write(6,*)     nameD2, size2
      STATUS = NF_INQ_DIM(NCID, 3, nameD3, size3)
      write(6,*)     nameD3, size3
      
      write(6,*) '  '
      write(6,*) ' Variables IDs '
      write(6,*) ' ------------- '
      STATUS = NF_INQ_VARID(NCID, 'LEVEL', var1ID)
      write(6,*)     var1ID      
      STATUS = NF_INQ_VARID(NCID, 'MAGLAT', var2ID)
      write(6,*)     var2ID    
      STATUS = NF_INQ_VARID(NCID, 'MLT', var3ID)
      write(6,*)     var3ID
      STATUS = NF_INQ_VARID(NCID, 'PRESSURE', var4ID)
      write(6,*)     var4ID      
      STATUS = NF_INQ_VARID(NCID, 'MIONE_N2', var5ID)
      write(6,*)     var5ID    
      STATUS = NF_INQ_VARID(NCID, 'MIONE_O', var6ID)
      write(6,*)     var6ID
      STATUS = NF_INQ_VARID(NCID, 'MIONE_O2', var7ID)
      write(6,*)     var7ID      
     
      write(6,*) '  ' 
      write(6,*) ' Information about variables(name, type, dim, att) '
      write(6,*) ' ------------------------------------------------- '
      STATUS = NF_INQ_VAR(NCID, 1, nameV1, type1, nDIM1, dims1ID, nATT1)
      write(6,*)     nameV1, type1, nDIM1, nATT1
      STATUS = NF_INQ_VAR(NCID, 2, nameV2, type2, nDIM2, dims2ID, nATT2)
      write(6,*)     nameV2, type2, nDIM2, nATT2
      STATUS = NF_INQ_VAR(NCID, 3, nameV3, type3, nDIM3, dims3ID, nATT3)
      write(6,*)     nameV3, type3, nDIM3, nATT3
      STATUS = NF_INQ_VAR(NCID, 4, nameV4, type4, nDIM4, dims4ID, nATT4)
      write(6,*)     nameV4, type4, nDIM4, nATT4
      STATUS = NF_INQ_VAR(NCID, 5, nameV5, type5, nDIM5, dims5ID, nATT5)
      write(6,*)     nameV5, type5, nDIM5, nATT5
      STATUS = NF_INQ_VAR(NCID, 6, nameV6, type6, nDIM6, dims6ID, nATT6)
      write(6,*)     nameV6, type6, nDIM6, nATT6      
      STATUS = NF_INQ_VAR(NCID, 7, nameV7, type7, nDIM7, dims7ID, nATT7)
      write(6,*)     nameV7, type7, nDIM7, nATT7      
      
            
      write(6,*) '  ' 
      write(6,*) ' Read the variables '
      write(6,*) ' ------------------ '
      STATUS = NF_GET_VAR_INT(NCID,  1, level) 
      STATUS = NF_GET_VAR_REAL(NCID, 2, maglat) 
      STATUS = NF_GET_VAR_REAL(NCID, 3, mlt)
      STATUS = NF_GET_VAR_REAL(NCID, 4, pressure)
      STATUS = NF_GET_VAR_REAL(NCID, 5, mione_N2) 
      STATUS = NF_GET_VAR_REAL(NCID, 6, mione_O)
      STATUS = NF_GET_VAR_REAL(NCID, 7, mione_O2)     
            
      write(6,*) ' '      
      STATUS = nf_close(NCID)
      IF (STATUS .NE. NF_NOERR) THEN
         PRINT *, NF_STRERROR(STATUS)      
      ELSE
         write(6,*) ' ------------------------------ '
         write(6,*) ' I have closed the ncdf for you '
         write(6,*) ' ------------------------------ '
      ENDIF
      write(6,*) '  '                      
      end
