"Fossies" - the Fresh Open Source Software Archive

Member "netcdf-fortran-4.4.5/nf_test/ftst_v2.F" (31 Jan 2019, 3835 Bytes) of package /linux/misc/netcdf-fortran-4.4.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Fortran 77 source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 C     This is part of the netCDF package.
    2 C     Copyright 2009 University Corporation for Atmospheric Research/Unidata.
    3 C     See COPYRIGHT file for conditions of use.
    4 
    5 C     This program tests the fortran V2 API with netCDF-4.
    6 
    7 C     $Id: ftst_v2.F,v 1.1 2009/01/27 19:49:11 ed Exp $
    8 
    9       program ftst_v2
   10       implicit none
   11       include 'netcdf.inc'
   12 
   13 C     This is the name of the data file we will create.
   14       character*(*) FILE_NAME
   15       parameter (FILE_NAME='ftst_v2.nc')
   16 
   17       integer ncid, timedim, londim, latdim, lonid, latid
   18       character*(3) lat_name
   19       parameter (lat_name = 'lat')
   20       character*(3) lon_name
   21       parameter (lon_name = 'lon')
   22       character*(4) time_name
   23       parameter (time_name = 'time')
   24       integer LON_LEN, LAT_LEN
   25       parameter (LON_LEN = 3, LAT_LEN = 5)
   26       integer NDIMS, NVARS
   27       parameter (NDIMS = 3, NVARS = 2)
   28       integer ndims_in, nvars_in, ngatts_in, recdim_in
   29       integer dimsize_in, natts_in
   30       integer xtype_in, dimids_in(NDIMS)
   31       character*(128) name_in
   32       integer rc
   33 
   34       print *, ''
   35       print *,'*** Testing v2 fortran API with netCDF-4.'
   36 
   37 C     Create the file.
   38       ncid = nccre(FILE_NAME, NF_NETCDF4, rc)
   39       timedim = ncddef(ncid, time_name, NCUNLIM, rc)
   40       londim = ncddef(ncid, lon_name, LON_LEN, rc)
   41       latdim = ncddef(ncid, lat_name, LAT_LEN, rc)
   42       lonid = ncvdef(ncid, lon_name, NCFLOAT, 1, londim, rc)
   43       latid = ncvdef(ncid, lat_name, NCFLOAT, 1, latdim, rc)
   44 
   45 C     Check the file.
   46       call ncinq(ncid, ndims_in, nvars_in, ngatts_in, recdim_in, rc)
   47       if (ndims_in .ne. NDIMS) stop 2
   48       if (ndims_in .ne. NDIMS .or. nvars_in .ne. NVARS .or.
   49      $     ngatts_in .ne. 0 .or. recdim_in .ne. timedim) stop 2
   50       call ncdinq(ncid, timedim, name_in, dimsize_in, rc)
   51       if (name_in .ne. time_name .or. dimsize_in .ne. 0) stop 2
   52       call ncdinq(ncid, londim, name_in, dimsize_in, rc)
   53       if (name_in .ne. lon_name .or. dimsize_in .ne. LON_LEN) stop 2
   54       call ncdinq(ncid, latdim, name_in, dimsize_in, rc)
   55       if (name_in .ne. lat_name .or. dimsize_in .ne. LAT_LEN) stop 2
   56       call ncvinq(ncid, lonid, name_in, xtype_in, ndims_in, dimids_in, 
   57      $     natts_in, rc)
   58       if (name_in .ne. lon_name .or. xtype_in .ne. NCFLOAT .or.
   59      $     ndims_in .ne. 1 .or. dimids_in(1) .ne. londim) stop 2
   60       call ncvinq(ncid, latid, name_in, xtype_in, ndims_in, dimids_in, 
   61      $     natts_in, rc)
   62       if (name_in .ne. lat_name .or. xtype_in .ne. NCFLOAT .or.
   63      $     ndims_in .ne. 1 .or. dimids_in(1) .ne. latdim) stop 2
   64 
   65 C     Close the file.
   66       call ncclos(ncid, rc)
   67 
   68 C     Reopen, and check again.
   69       ncid = ncopn(FILE_NAME, NCNOWRIT, rc)
   70 C     Check the file.
   71       call ncinq(ncid, ndims_in, nvars_in, ngatts_in, recdim_in, rc)
   72       if (ndims_in .ne. NDIMS) stop 2
   73       if (ndims_in .ne. NDIMS .or. nvars_in .ne. NVARS .or.
   74      $     ngatts_in .ne. 0 .or. recdim_in .ne. timedim) stop 2
   75       call ncdinq(ncid, timedim, name_in, dimsize_in, rc)
   76       if (name_in .ne. time_name .or. dimsize_in .ne. 0) stop 2
   77       call ncdinq(ncid, londim, name_in, dimsize_in, rc)
   78       if (name_in .ne. lon_name .or. dimsize_in .ne. LON_LEN) stop 2
   79       call ncdinq(ncid, latdim, name_in, dimsize_in, rc)
   80       if (name_in .ne. lat_name .or. dimsize_in .ne. LAT_LEN) stop 2
   81       call ncvinq(ncid, lonid, name_in, xtype_in, ndims_in, dimids_in, 
   82      $     natts_in, rc)
   83       if (name_in .ne. lon_name .or. xtype_in .ne. NCFLOAT .or.
   84      $     ndims_in .ne. 1 .or. dimids_in(1) .ne. londim) stop 2
   85       call ncvinq(ncid, latid, name_in, xtype_in, ndims_in, dimids_in, 
   86      $     natts_in, rc)
   87       if (name_in .ne. lat_name .or. xtype_in .ne. NCFLOAT .or.
   88      $     ndims_in .ne. 1 .or. dimids_in(1) .ne. latdim) stop 2
   89 
   90       call ncclos(ncid, rc)
   91 
   92       print *,'*** SUCCESS!'
   93       end
   94