Changeset 13071


Ignore:
Timestamp:
08/16/12 15:30:45 (13 years ago)
Author:
jschierm
Message:

NEW: More changes for python marshalling and running (plus corresponding matlab changes).

Location:
issm/trunk-jpl/src/m
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/os/issmscpin.m

    r12743 r13071  
    1 function scpin(host, login,port,path, packages)
    2 %SCPIN get packages from host, using scp on unix, and pscp on windows
     1function issmscpin(host, login,port,path, packages)
     2%ISSMSCPIN get packages from host, using scp on unix, and pscp on windows
    33%
    4 %   usage: scpin(host,packages,path)
     4%   usage: issmscpin(host,packages,path)
    55%
    66%
     
    3535                [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
    3636                if status,
    37                         error('scpin error message: could not find ISSM_DIR_WIN environment variable');
     37                        error('issmscpin error message: could not find ISSM_DIR_WIN environment variable');
    3838                end
    3939                ISSM_DIR=ISSM_DIR(2:end-2);
     
    4545                        [status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' host ':' path '/' packages{i} ' ./']);
    4646                        if status,
    47                                 error('scpin error message: could not call putty pscp');
     47                                error('issmscpin error message: could not call putty pscp');
    4848                        end
    4949                end
     
    7272                for i=1:numel(packages),
    7373                        if ~exist(['./' packages{i}]),
    74                                 error('scpin error message: could not call scp on *nix system');
     74                                error('issmscpin error message: could not call scp on *nix system');
    7575                        end
    7676                end
  • issm/trunk-jpl/src/m/os/issmscpin.py

    r12944 r13071  
    66from MatlabFuncs import *
    77
    8 def scpin(host, login,port,path, packages):
     8def issmscpin(host, login,port,path, packages):
    99        """
    10         SCPIN get packages from host, using scp on unix, and pscp on windows
     10        ISSMSCPIN get packages from host, using scp on unix, and pscp on windows
    1111 
    12            usage: scpin(host,packages,path)
     12           usage: issmscpin(host,packages,path)
    1313        """
    1414
     
    4242                                ISSM_DIR=os.environ['ISSM_DIR_WIN'][1:-2]
    4343                        else:
    44                                 raise OSError("scpin error message: could not find ISSM_DIR_WIN environment variable.")
     44                                raise OSError("issmscpin error message: could not find ISSM_DIR_WIN environment variable.")
    4545
    4646                        username=raw_input('Username: (quoted string) ')
     
    5151                                        subprocess.check_call('%s/externalpackages/ssh/pscp.exe -l "%s" -pw "%s" %s:%s %s' % (ISSM_DIR,username,key,host,os.path.join(path,package),os.getcwd()),shell=True)
    5252                                except CalledProcessError as e:
    53                                         raise CalledProcessError("scpin error message: could not call putty pscp.")
     53                                        raise CalledProcessError("issmscpin error message: could not call putty pscp.")
    5454
    5555                else:
     
    7373                        for package in packages:
    7474                                if not os.path.exists(os.path.join('.',package)):
    75                                         raise OSError("scpin error message: could not call scp on *nix system.")
     75                                        raise OSError("issmscpin error message: could not call scp on *nix system.")
    7676
  • issm/trunk-jpl/src/m/os/issmscpout.m

    r12743 r13071  
    11function issmscpout(host,path,login,port,packages)
    2 %SCPOUT send packages to a host, using scp on unix, and pscp on windows
     2%ISSMSCPOUT send packages to a host, using scp on unix, and pscp on windows
    33%
    4 %   usage: scpout(host,path,packages)
     4%   usage: issmscpout(host,path,packages)
    55%
    66%
     
    2626                [status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
    2727                if status,
    28                         error('scpout error message: could not find ISSM_DIR_WIN environment variable');
     28                        error('issmscpout error message: could not find ISSM_DIR_WIN environment variable');
    2929                end
    3030                ISSM_DIR=ISSM_DIR(2:end-2);
     
    3636                        [status,result]=system([ISSM_DIR '/externalpackages/ssh/pscp.exe -l "' username '" -pw "' key '" ' packages{i} ' ' host ':' path]);
    3737                        if status,
    38                                 error('scpout error message: could not call putty pscp');
     38                                error('issmscpout error message: could not call putty pscp');
    3939                        end
    4040                end
  • issm/trunk-jpl/src/m/os/issmscpout.py

    r13043 r13071  
    33import subprocess
    44import os
    5 import shutil
    65from MatlabFuncs import *
    76
    87def issmscpout(host,path,login,port,packages):
    98        """
    10         SCPOUT send packages to a host, using scp on unix, and pscp on windows
     9        ISSMSCPOUT send packages to a host, using scp on unix, and pscp on windows
    1110 
    12            usage: scpout(host,path,packages)
     11           usage: issmscpout(host,path,packages)
    1312        """
    14 
    15         print "host=",host
    16         print "path=",path
    17         print "login=",login
    18         print "port=",port
    19         print "packages=",packages
    2013
    2114        #get hostname
     
    2821                        here=os.getcwd()
    2922                        os.chdir(path)
    30                         shutil.rmtree(package)
     23                        try:
     24                                os.remove(package)
     25                        except OSError as e:
     26                                pass
    3127                        subprocess.call('ln -s %s %s' % (os.path.join(here,package),path),shell=True)
    3228                        os.chdir(here)
     
    3935                                ISSM_DIR=os.environ['ISSM_DIR_WIN'][1:-2]
    4036                        else:
    41                                 raise OSError("scpout error message: could not find ISSM_DIR_WIN environment variable.")
     37                                raise OSError("issmscpout error message: could not find ISSM_DIR_WIN environment variable.")
    4238
    4339                        username=raw_input('Username: (quoted string) ')
     
    4844                                        subprocess.check_call('%s/externalpackages/ssh/pscp.exe -l "%s" -pw "%s" %s %s:%s' % (ISSM_DIR,username,key,package,host,path),shell=True)
    4945                                except CalledProcessError as e:
    50                                         raise CalledProcessError("scpout error message: could not call putty pscp.")
     46                                        raise CalledProcessError("issmscpout error message: could not call putty pscp.")
    5147
    5248                else:
  • issm/trunk-jpl/src/m/parameterization/parameterize.m

    r13018 r13071  
    5656end
    5757md.miscellaneous.notes=['Model created by using parameter file: ' parametername ' on: ' datestr(now)];
     58
  • issm/trunk-jpl/src/m/solve/WriteData.py

    r13043 r13071  
    104104                        data=numpy.array([data])
    105105                if len(data.shape) == 1:
    106                         data=data.reshape(numpy.size(data,0),1)
     106                        data=data.reshape(1,numpy.size(data,0))
    107107
    108108                #Get size
     
    124124                for i in xrange(s[0]):
    125125                        for j in xrange(s[1]):
    126                                 fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
     126                                fid.write(struct.pack('d',float(data[i][j])))    #get to the "c" convention, hence the transpose
    127127                # }}}
    128128
     
    132132                        data=numpy.array([data])
    133133                if len(data.shape) == 1:
    134                         data=data.reshape(numpy.size(data,0),1)
     134                        data=data.reshape(1,numpy.size(data,0))
    135135
    136136                #Get size
     
    152152                for i in xrange(s[0]):
    153153                        for j in xrange(s[1]):
    154                                 fid.write(struct.pack('i',data[i][j]))    #get to the "c" convention, hence the transpose
     154                                fid.write(struct.pack('d',float(data[i][j])))    #get to the "c" convention, hence the transpose
    155155                # }}}
    156156
    157157        elif strcmpi(format,'DoubleMat'):    # {{{
    158158
    159                 if isinstance(data,(int,long,float)):
     159                if isinstance(data,(bool,int,long,float)):
    160160                        data=numpy.array([data])
    161161                if len(data.shape) == 1:
    162                         data=data.reshape(numpy.size(data,0),1)
     162                        data=data.reshape(1,numpy.size(data,0))
    163163
    164164                #Get size
     
    180180                for i in xrange(s[0]):
    181181                        for j in xrange(s[1]):
    182                                 fid.write(struct.pack('d',data[i][j]))    #get to the "c" convention, hence the transpose
     182                                fid.write(struct.pack('d',float(data[i][j])))    #get to the "c" convention, hence the transpose
    183183                # }}}
    184184
     
    188188                recordlength=4+4    #number of records + code
    189189                for matrix in data:
     190                        if isinstance(matrix,(bool,int,long,float)):
     191                                matrix=numpy.array([matrix])
     192                        if len(matrix.shape) == 1:
     193                                matrix=matrix.reshape(1,numpy.size(matrix,0))
     194
    190195                        s=matrix.shape
    191196                        recordlength+=4*2+s[0]*s[1]*8    #row and col of matrix + matrix of doubles
     
    202207                #write each matrix:
    203208                for matrix in data:
     209                        if isinstance(matrix,(bool,int,long,float)):
     210                                matrix=numpy.array([matrix])
     211                        if len(matrix.shape) == 1:
     212                                matrix=matrix.reshape(1,numpy.size(matrix,0))
     213
    204214                        s=matrix.shape
    205215                        fid.write(struct.pack('i',s[0]))
     
    207217                        for i in xrange(s[0]):
    208218                                for j in xrange(s[1]):
    209                                         fid.write(struct.pack('d',matrix[i][j]))
     219                                        fid.write(struct.pack('d',float(matrix[i][j])))
    210220                # }}}
    211221
  • issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py

    r13023 r13071  
    33import socket
    44from MatlabFuncs import *
     5from loadresultsfromdisk import *
    56
    67def loadresultsfromcluster(md,runtimename=False):
     
    1718        if runtimename:
    1819                md.private.runtimename=runtimename
    19         end
    2020
    2121        #Download outputs from the cluster
     
    2828                                filelist.append('dakota_tabular.dat')
    2929                filelist.append(md.miscellaneous.name+'.outbin')
    30         Download(cluster,md.private.runtimename,filelist)
     30        cluster.Download(md.private.runtimename,filelist)
    3131
    3232        #If we are here, no errors in the solution sequence, call loadresultsfromdisk.
  • issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py

    r13043 r13071  
    11import os
     2from parseresultsfromdisk import *
    23from EnumToString import EnumToString
    34
     
    2829                if not len(structure):
    2930                        raise RuntimeError("No result found in binary file '%s'. Check for solution crash." % filename)
    30                 end
    3131                md.results[structure[1]['SolutionType']]=structure;
    3232
  • issm/trunk-jpl/src/m/solve/solve.py

    r13043 r13071  
    99from marshall import *
    1010from ispetsc import *
     11from waitonlock import *
     12from loadresultsfromcluster import *
    1113
    1214def solve(md,solutionenum,*args):
     
    7981        marshall(md)                                           # bin file
    8082        md.solver.PetscFile(md.miscellaneous.name+'.petsc')    # petsc file
    81         cluster.BuildQueueScript(md.miscellaneous.name,md.private.runtimename,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof)    # queue file
     83        cluster.BuildQueueScript(md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof)    # queue file
    8284
    8385        #we need to make sure we have PETSC support, otherwise, we run with only one cpu:
  • issm/trunk-jpl/src/m/solve/waitonlock.m

    r13006 r13071  
    1 function flag=waitonlock(md,executionpath,login,port)
     1function flag=waitonlock(md)
    22%WAITONLOCK - wait for a file
    33%
     
    66%
    77%   Usage:
    8 %      flag=waitonlock(md,executionpath)
     8%      flag=waitonlock(md)
    99
    1010%Get filename (lock file) and options
  • issm/trunk-jpl/src/m/solve/waitonlock.py

    r13006 r13071  
    44from MatlabFuncs import *
    55
    6 def waitonlock(md,executionpath,login,port):
     6def waitonlock(md):
    77        """
    88        WAITONLOCK - wait for a file
     
    1212 
    1313           Usage:
    14               flag=waitonlock(md,executionpath)
     14              flag=waitonlock(md)
    1515        """
    1616
Note: See TracChangeset for help on using the changeset viewer.