Changeset 12651


Ignore:
Timestamp:
07/18/12 14:11:21 (13 years ago)
Author:
jschierm
Message:

Conversion of runme.py from hdf5 to netcdf (along with other cosmetic changes).

Location:
issm/trunk-jpl/test
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/runme.py

    r12639 r12651  
    11#! /usr/bin/env python
    2 """RUNME - test deck for ISSM nightly runs"""
    3 #
    4 #   In a test deck directory (tests/Vertification/NightlyRun for example)
    5 #   The following command will launch all the existing tests:
    6 #   >> runme
    7 #   To run the tests 101 and 102:
    8 #   >> runme('id',[101 102])
    9 #   etc...
    10 #
    11 #   Available options:
    12 #      'id'            followed by the list of ids requested
    13 #      'exclude'       ids to be excluded from the test
    14 #      'benchmark'     'nightly' (nightly run/ daily run)
    15 #                      'ismip'  : validation of ismip-hom tests
    16 #                      'eismint': validation of eismint tests
    17 #                      'thermal': validation of thermal tests
    18 #                      'mesh'   : validation of mesh tests
    19 #                      ...
    20 #      'procedure'     'check' : run the test (default)
    21 #                      'update': update the archive
    22 #                      'model' : prepare the model but no test is run
    23 #
    24 #   Usage:
    25 #      md=runme(varargin);
    26 #
    27 #   Examples:
    28 #      runme;
    29 #      runme('exclude',101);
    30 #      md=runme('id',102,'procedure','model');
     2"""
     3RUNME - test deck for ISSM nightly runs
     4 
     5    In a test deck directory (tests/Vertification/NightlyRun for example)
     6    The following command will launch all the existing tests:
     7    >>> runme()
     8    To run the tests 101 and 102:
     9    >>> runme(id=[101,102])
     10    etc...
     11 
     12    Available options:
     13       'id'            followed by the list of ids requested
     14       'exclude'       ids to be excluded from the test
     15       'benchmark'     'nightly' (nightly run/ daily run)
     16                       'ismip'  : validation of ismip-hom tests
     17                       'eismint': validation of eismint tests
     18                       'thermal': validation of thermal tests
     19                       'mesh'   : validation of mesh tests
     20                       ...
     21       'procedure'     'check' : run the test (default)
     22                       'update': update the archive
     23 
     24    Usage:
     25       md=runme(varargin);
     26 
     27    Examples:
     28       runme()
     29       runme(exclude=101)
     30       md=runme(id=102,procedure='update')
     31"""
    3132
    3233import os
     
    3435import socket
    3536import numpy
    36 import h5py
     37#import h5py
     38import netCDF4
    3739import sys
    3840from parallelrange import parallelrange
     
    142144#                                       raise RuntimeError("Nightly run archives must be saved on 'larsen' (hostname is '"+socket.gethostname()+"').")
    143145                                        print "Nightly run archives must be saved on 'larsen' (hostname is '"+socket.gethostname()+"')."
    144                                 f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'w')
     146#                               f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'w')
     147                                f = netCDF4.Dataset(os.path.join('..','Archives',archive_name+'.nc'),'w')
    145148                                for k,fieldname in enumerate(field_names):
    146149                                        field=numpy.array(field_values[k],dtype=float)
    147                                         f.create_dataset(archive_name+'_field'+str(k),data=field)
     150#                                       f.create_dataset(archive_name+'_field'+str(k),data=field)
     151                                        f.createDimension(archive_name+'_field'+str(k)+'_0',numpy.size(field,0))
     152                                        f.createDimension(archive_name+'_field'+str(k)+'_1',numpy.size(field,1))
     153                                        v = f.createVariable(archive_name+'_field'+str(k),'f8',(archive_name+'_field'+str(k)+'_0',archive_name+'_field'+str(k)+'_1'))
     154                                        v[:] = field
    148155                                f.close()
    149                                 print "File '%s' saved.\n" % os.path.join('..','Archives',archive_name+'.hdf5')
     156                                print "File '%s' saved.\n" % os.path.join('..','Archives',archive_name+'.nc')
    150157
    151158                        #ELSE: CHECK TEST
     
    153160
    154161                                #load archive
    155                                 if os.path.exists(os.path.join('..','Archives',archive_name+'.hdf5')):
    156                                         f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'r')
     162                                if os.path.exists(os.path.join('..','Archives',archive_name+'.nc')):
     163#                                       f = h5py.File(os.path.join('..','Archives',archive_name+'.hdf5'),'r')
     164                                        f = netCDF4.Dataset(os.path.join('..','Archives',archive_name+'.nc'),'r')
    157165                                else:
    158                                         raise IOError("Archive file '"+os.path.join('..','Archives',archive_name+'.hdf5')+"' does not exist.")
     166                                        raise IOError("Archive file '"+os.path.join('..','Archives',archive_name+'.nc')+"' does not exist.")
    159167
    160168                                for k,fieldname in enumerate(field_names):
     
    168176
    169177                                                #compare to archive
    170                                                 if archive_name+'_field'+str(k) in f:
    171                                                         archive=f[archive_name+'_field'+str(k)][...]
     178#                                               if archive_name+'_field'+str(k) in f:
     179#                                                       archive=f[archive_name+'_field'+str(k)][...]
     180                                                if archive_name+'_field'+str(k) in f.variables:
     181                                                        archive=f.variables[archive_name+'_field'+str(k)][:]
    172182                                                else:
    173183                                                        raise NameError("Field name '"+archive_name+'_field'+str(k)+"' does not exist in archive file.")
Note: See TracChangeset for help on using the changeset viewer.