Example #1
0
def regress_wetdry(code_path):
    case_name = 'wetdry'
    include_name = 'wetdry_dam_break'
    base_bashfile = 'coawst.bash'
    base_runfile = 'run_nemo'
    oceaninfile = 'ocean_wetdry_dam_break.in'
    project_str = 'Projects' + '/' + case_name
    project_path = os.path.join(code_path, project_str)
    case_subpath = project_path  # this is different for case within a subfolder
    couple_flag = '1way'
    ntilex = 4
    ntiley = 2
    tot_nproc = ntilex * ntiley
    nodes = 1  # for NEMO ppn=8
    execute = 'coawstM'
    logfile = 'log.out_' + case_name
    buildfile = 'Build.txt'

    os.chdir(code_path)
    """ Make local copies for each case """
    bashfile = base_bashfile + "_" + case_name
    shutil.copy2(base_bashfile, bashfile)

    runfile = base_runfile + "_" + case_name
    shutil.copy2(base_runfile, runfile)

    util.edit_bashfile(bashfile, include_name, code_path, project_path)

    print "------------------------------------------"
    print "Compiling:", case_name, "case"
    os.system('./%(bashfile)s >>Build.txt 2>&1' % locals())

    util.edit_jobscript(runfile,oceaninfile,case_name,project_str,code_path,\
                         tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_oceaninfile(oceaninfile, ntilex, ntiley)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing test :", case_name
    p = subprocess.Popen("qsub %(runfile)s" % locals(),
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()

    #check every ten mins
    stdout_case = stdout
    util.check_queue(stdout_case)

    #if it is done it will get out of loop

    #   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile, \
                        execute,stdout,logfile)
def regress_ripcurrent(code_path):
    case_name       ='Rip_current'
    base_bashfile   ='coawst.bash' 
    base_runfile    ='run_nemo'
    oceaninfile     ='ocean_%s.in' % (case_name.lower())
    couplefile      = 'coupling_%s.in'  % (case_name.lower())
    project_str     ='Projects'+'/'+case_name
    project_path    =os.path.join(code_path,project_str)
    case_subpath    =project_path # this is different for case within a subfolder
    couple_flag     ='2way'
    ntilex          = 2
    ntiley          = 2
    nocn            = ntilex*ntiley      # this is for ROMS
    nwav            = 4                  # this is for SWAN
    natm            = 0                  # this is for wrf
    tot_nproc       = nocn+nwav+natm
    nodes           = 1                  # for NEMO, PPN=8 
    executable      = 'coawstM'
    logfile         = 'log.out_' + case_name
    buildfile       = 'Build.txt'

    os.chdir(code_path)
    """ Make local copies for each case """
    bashfile  = base_bashfile + "_" + case_name 
    shutil.copy2(base_bashfile,bashfile)
      
    runfile   = base_runfile + "_" + case_name
    shutil.copy2(base_runfile,runfile)
 
    util.edit_bashfile(bashfile,case_name,code_path,project_path)

    print "------------------------------------------"
    print "Compiling:", case_name,"case"
    os.system('./%(bashfile)s  >>Build.txt 2>&1' %locals() )

    util.edit_jobscript(runfile,couplefile,case_name,project_str,code_path,\
                        tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
    util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing case :", case_name
    p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE) 
    stdout,stderr=p.communicate()

#check every ten mins
    stdout_case=stdout
    util.check_queue(stdout_case)

#   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile,\
                        executable,stdout,logfile)
Example #3
0
def regress_wetdry(code_path):
    case_name       ='wetdry'
    include_name    ='wetdry_dam_break'
    base_bashfile   ='coawst.bash' 
    base_runfile    ='run_nemo'
    oceaninfile     ='ocean_wetdry_dam_break.in'
    project_str     ='Projects'+'/'+case_name
    project_path    =os.path.join(code_path,project_str)
    case_subpath    =project_path # this is different for case within a subfolder
    couple_flag     ='1way'
    ntilex          = 4
    ntiley          = 2
    tot_nproc       = ntilex*ntiley
    nodes           = 1    # for NEMO ppn=8 
    execute         = 'coawstM'
    logfile         = 'log.out_' + case_name
    buildfile       = 'Build.txt'

    os.chdir(code_path)
    """ Make local copies for each case """
    bashfile  = base_bashfile + "_" + case_name 
    shutil.copy2(base_bashfile,bashfile)
      
    runfile   = base_runfile + "_" + case_name
    shutil.copy2(base_runfile,runfile)
 
    util.edit_bashfile(bashfile,include_name,code_path,project_path)
 
    print "------------------------------------------"
    print "Compiling:", case_name,"case"
    os.system('./%(bashfile)s >>Build.txt 2>&1' %locals() )

    util.edit_jobscript(runfile,oceaninfile,case_name,project_str,code_path,\
                         tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing test :", case_name
    p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE) 
    stdout,stderr=p.communicate()

#check every ten mins
    stdout_case=stdout
    util.check_queue(stdout_case)

#if it is done it will get out of loop
    
#   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile, \
                        execute,stdout,logfile)
def regress_inlet(code_path):
    case_name       ='Inlet_test'
    base_bashfile   ='coawst.bash'
    base_runfile    ='run_nemo'
    couple_flag     ='2way'
    ntilex          = 2
    ntiley          = 2
    ntilex_ref      = "2  2"            #This is for "Refined" mesh 
    ntiley_ref      = "2  2"            #This is for "Refined" mesh 
    nocn            = ntilex*ntiley
    nwav            = 4
    natm            = 0
    tot_nproc       = nocn+nwav+natm
    nodes           = 1                 # for NEMO, ppn = 8 
    executable      = 'coawstM'
    buildfile       = 'Build.txt'

    inlet_tests=os.listdir(os.path.join(code_path,'Projects/Inlet_test'))    
    ignored = ['.svn']
    inlet_tests= [x for x in inlet_tests if x not in ignored]

    print "----------------------------------------------"
    print " INLET TEST CASES INCLUDED:", inlet_tests

    for each_inlet_case in inlet_tests: 
        project_str='Projects/Inlet_test'+'/'+each_inlet_case
        project_subpath=os.path.join(code_path,project_str)
        
        os.chdir(code_path)

        bashfile  = base_bashfile + '_inlet_' + each_inlet_case
        shutil.copy2(base_bashfile,bashfile)

        runfile   = base_runfile + '_inlet_' + each_inlet_case
        shutil.copy2(base_runfile,runfile)
       
        """ Edit 'coawst.bash' for each case """
        util.edit_bashfile(bashfile,case_name,code_path,project_subpath)     

        os.system('./%(bashfile)s  >>Build.txt 2>&1' %locals() )
        print "------------------------------------------"
        print "Finished compiling Inlet test:", each_inlet_case
       
        case_subname = "Inlet_test_" + each_inlet_case

        if each_inlet_case == 'DiffGrid': 
            inputfile='coupling_inlet_test_diffgrid.in' 
	    oceaninfile='ocean_inlet_test.in'
            couplefile=inputfile 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
            util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

            os.chdir(code_path)
 
            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,    \
                                stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()
           
            #check every ten mins
            stdout_case=stdout 
            util.check_queue(stdout_case)
          
            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Coupled': 
            inputfile='coupling_inlet_test.in' 
            oceaninfile='ocean_inlet_test.in'
            couplefile=inputfile 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    
          
            os.chdir(project_subpath)
            util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
            util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,     \
                               stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()

            #check every ten mins
            stdout_case=stdout 
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Refined':
            inputfile='coupling_inlet_test_ref3.in' 
            oceaninfile='ocean_inlet_test_ref3.in'
            couplefile=inputfile 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
# For refined case the ocean file function is changed in the same script
            util.edit_ref_oceaninfile(oceaninfile,ntilex_ref,ntiley_ref)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,     \
                               stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()

            #check every ten mins
            stdout_case=stdout 
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Swanonly': 
            inputfile='swan_inlet_test.in' 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,      \
                                stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()

            #check every ten mins
            stdout_case=stdout 
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)
Example #5
0
def regress_inlet(code_path):
    case_name = 'Inlet_test'
    base_bashfile = 'coawst.bash'
    base_runfile = 'run_nemo'
    couple_flag = '2way'
    ntilex = 2
    ntiley = 2
    ntilex_ref = "2  2"  #This is for "Refined" mesh
    ntiley_ref = "2  2"  #This is for "Refined" mesh
    nocn = ntilex * ntiley
    nwav = 4
    natm = 0
    tot_nproc = nocn + nwav + natm
    nodes = 1  # for NEMO, ppn = 8
    executable = 'coawstM'
    buildfile = 'Build.txt'

    inlet_tests = os.listdir(os.path.join(code_path, 'Projects/Inlet_test'))
    ignored = ['.svn']
    inlet_tests = [x for x in inlet_tests if x not in ignored]

    print "----------------------------------------------"
    print " INLET TEST CASES INCLUDED:", inlet_tests

    for each_inlet_case in inlet_tests:
        project_str = 'Projects/Inlet_test' + '/' + each_inlet_case
        project_subpath = os.path.join(code_path, project_str)

        os.chdir(code_path)

        bashfile = base_bashfile + '_inlet_' + each_inlet_case
        shutil.copy2(base_bashfile, bashfile)

        runfile = base_runfile + '_inlet_' + each_inlet_case
        shutil.copy2(base_runfile, runfile)
        """ Edit 'coawst.bash' for each case """
        util.edit_bashfile(bashfile, case_name, code_path, project_subpath)

        os.system('./%(bashfile)s  >>Build.txt 2>&1' % locals())
        print "------------------------------------------"
        print "Finished compiling Inlet test:", each_inlet_case

        case_subname = "Inlet_test_" + each_inlet_case

        if each_inlet_case == 'DiffGrid':
            inputfile = 'coupling_inlet_test_diffgrid.in'
            oceaninfile = 'ocean_inlet_test.in'
            couplefile = inputfile
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile, natm, nwav, nocn, couple_flag)
            util.edit_oceaninfile(oceaninfile, ntilex, ntiley)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,    \
                                stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout, stderr = p.communicate()

            #check every ten mins
            stdout_case = stdout
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Coupled':
            inputfile = 'coupling_inlet_test.in'
            oceaninfile = 'ocean_inlet_test.in'
            couplefile = inputfile
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile, natm, nwav, nocn, couple_flag)
            util.edit_oceaninfile(oceaninfile, ntilex, ntiley)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,     \
                               stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout, stderr = p.communicate()

            #check every ten mins
            stdout_case = stdout
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Refined':
            inputfile = 'coupling_inlet_test_ref3.in'
            oceaninfile = 'ocean_inlet_test_ref3.in'
            couplefile = inputfile
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile, natm, nwav, nocn, couple_flag)
            # For refined case the ocean file function is changed in the same script
            util.edit_ref_oceaninfile(oceaninfile, ntilex_ref, ntiley_ref)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,     \
                               stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout, stderr = p.communicate()

            #check every ten mins
            stdout_case = stdout
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_inlet_case == 'Swanonly':
            inputfile = 'swan_inlet_test.in'
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)

            print "------------------------------------------"
            print "Executing Inlet_test:", each_inlet_case
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,      \
                                stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout, stderr = p.communicate()

            #check every ten mins
            stdout_case = stdout
            util.check_queue(stdout_case)

            logfile = 'log.out_' + case_subname

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)
def regress_shoreface(code_path):
    case_name = 'Shoreface'
    oceaninfile = 'ocean_%s.in' % (case_name.lower())
    includefile = '%s.h' % (case_name.lower())
    # COPY SHOREFACE FILES IN A NEW FOLDER and COPY IN PROJECTS FOLDER
    # This is special for SHOREFACE case
    project_str = 'Projects'
    project_path = os.path.join(code_path, project_str)
    os.chdir(project_path)
    os.makedirs(case_name)
    #    try:
    #        os.makedirs(case_name)
    #    except OSError as e:
    #        if e.errno != errno.EEXIST:
    #	print "SHOREFACE directory already exists"
    #        raise  # raises the error again

    # Project path
    project_str = 'Projects' + '/' + case_name
    project_path = os.path.join(code_path, project_str)

    os.chdir(code_path)

    # Get ocean_shoreface.in file from ROMS/External folder
    romsexternal = 'ROMS/External'
    romsexternalpath = os.path.join(code_path, romsexternal)
    os.chdir(romsexternalpath)
    shutil.copy2(oceaninfile, project_path)

    # Get shoreface.h file from ROMS/Include folder
    romsinclude = 'ROMS/Include'
    romsincludepath = os.path.join(code_path, romsinclude)
    os.chdir(romsincludepath)
    shutil.copy2(includefile, project_path)

    base_bashfile = 'coawst.bash'
    base_runfile = 'run_nemo'
    case_subpath = project_path  # this is different for case within a subfolder
    couple_flag = '1way'
    ntilex = 4
    ntiley = 2
    tot_nproc = ntilex * ntiley
    nodes = 1  # for NEMO ppn=8
    execute = 'coawstM'
    logfile = 'log.out_' + case_name
    buildfile = 'Build.txt'

    os.chdir(code_path)
    """ Make local copies for each case """
    bashfile = base_bashfile + "_" + case_name
    shutil.copy2(base_bashfile, bashfile)

    runfile = base_runfile + "_" + case_name
    shutil.copy2(base_runfile, runfile)

    util.edit_bashfile(bashfile, case_name, code_path, project_path)

    print "------------------------------------------"
    print "Compiling:", case_name, "case"
    os.system('./%(bashfile)s >>Build.txt 2>&1' % locals())

    util.edit_jobscript(runfile,oceaninfile,case_name,project_str,code_path,\
                         tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_oceaninfile(oceaninfile, ntilex, ntiley)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing test :", case_name
    p = subprocess.Popen("qsub %(runfile)s" % locals(),
                         shell=True,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()

    #check every ten mins
    stdout_case = stdout
    util.check_queue(stdout_case)

    #if it is done it will get out of loop

    #   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile, \
                        execute,stdout,logfile)
Example #7
0
def regress_joetc(code_path):
    case_name='JOE_TC'
    base_bashfile   ='coawst.bash' 
    base_runfile    ='run_nemo'
    couple_flag     ='3way'
    ntilex          = 4
    ntiley          = 2
    nocn            = ntilex*ntiley
    nwav            = 4
    nprocx_atm      = 2
    nprocy_atm      = 2
    natm            = nprocx_atm*nprocy_atm
    tot_nproc       = nocn+nwav+natm 
    nodes           = 2                     # for NEMO, PPN=8 
    executable      = 'coawstM'
    buildfile       = 'Build.txt'

    ignored     = ["namelist.input","wrfbdy_d01","wrfinput_d01",".svn"]
    path_inputs = os.path.join(code_path,'Projects/JOE_TC')
    joetc_tests = [x for x in os.listdir(path_inputs) if x not in ignored]
    print "----------------------------------------------"
    print " The JOE_TC testcases included:", joetc_tests

    os.chdir(path_inputs)
    util.edit_wrfinfile('namelist.input',nprocx_atm,nprocy_atm)
    wrffiles=['namelist.input','wrfbdy_d01','wrfinput_d01']

    for filename in wrffiles:
        shutil.copy(filename,code_path)

    os.chdir(code_path)
    for each_joetc_case in joetc_tests: 
        project_str='Projects/JOE_TC'+'/'+each_joetc_case
        project_subpath=os.path.join(code_path,project_str)

        bashfile  = base_bashfile + '_joetc_' + each_joetc_case
        shutil.copy2(base_bashfile,bashfile)

        runfile   = base_runfile + '_joetc_' + each_joetc_case
        shutil.copy2(base_runfile,runfile)

        """ Edit 'coawst.bash' for each case """
        util.edit_bashfile(bashfile,case_name,code_path,project_subpath)     

        print "------------------------------------------"
        print " Make clean WRF:", case_name, "case"
        """ enter the WRF folder """
        WRF_path=os.path.join(code_path,'WRF')
        os.chdir(WRF_path)
        os.system('./clean -a  >>Build.txt 2>&1')

        """ Change back to code_path """
        os.chdir(code_path)

        """ copy the configure file in WRF folder """
        src_wrf_conf = os.path.abspath('../coawst_regress_baseline/WRF_config_file/configure.wrf')
        dest2=os.path.join(code_path,'WRF')
        shutil.copy(src_wrf_conf,dest2)
         
        """ Compile the COAWST code """
        print "------------------------------------------"
        print "Compiling JOE TC test :", each_joetc_case
        os.system('./%(bashfile)s  >>Build.txt 2>&1' %locals() )

        case_subname="JOE_TC_" + each_joetc_case
        logfile     ='log.out_'+ case_subname

        if each_joetc_case == 'Coupled': 
            inputfile       ='coupling_joe_tc.in' 
            couplefile      = inputfile
            oceaninfile     = 'ocean_joe_tc.in' 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
            util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing JOE TC test :", each_joetc_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,    \
                               stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()

            #check every ten mins
            stdout_case=stdout
            util.check_queue(stdout_case)

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

        elif each_joetc_case == 'DiffGrid': 
            inputfile       ='coupling_joe_tc.in' 
            couplefile      = inputfile
            oceaninfile     = 'ocean_joe_tc_coarse.in' 
            util.edit_jobscript(runfile,inputfile,case_subname,project_str,\
                                code_path,tot_nproc,nodes)    

            os.chdir(project_subpath)
            util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)
            util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

            os.chdir(code_path)

            print "------------------------------------------"
            print "Executing JOE TC test :", each_joetc_case 
            p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,   \
                                stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            stdout,stderr=p.communicate()

            #check every ten mins
            stdout_case=stdout
            util.check_queue(stdout_case)

            #   Moving output files to each projects folder
            util.move_casefiles(project_subpath,case_subname,bashfile,runfile,\
                                buildfile,executable,stdout,logfile)

    #   Remove WRF files from the code path
    for filename in wrffiles:
        os.remove(filename)
def regress_shoreface(code_path):
    case_name       ='Shoreface'
    oceaninfile     ='ocean_%s.in' % (case_name.lower())
    includefile     ='%s.h' % (case_name.lower())
# COPY SHOREFACE FILES IN A NEW FOLDER and COPY IN PROJECTS FOLDER
# This is special for SHOREFACE case 
    project_str     ='Projects'
    project_path    =os.path.join(code_path,project_str)
    os.chdir(project_path)
    os.makedirs(case_name)
#    try:
#        os.makedirs(case_name)
#    except OSError as e:
#        if e.errno != errno.EEXIST:
#	print "SHOREFACE directory already exists"
#        raise  # raises the error again
  
# Project path 
    project_str     ='Projects'+'/'+case_name
    project_path    =os.path.join(code_path,project_str)
    
    os.chdir(code_path)

# Get ocean_shoreface.in file from ROMS/External folder
    romsexternal    ='ROMS/External'
    romsexternalpath= os.path.join(code_path,romsexternal)
    os.chdir(romsexternalpath)
    shutil.copy2(oceaninfile,project_path)

# Get shoreface.h file from ROMS/Include folder
    romsinclude     ='ROMS/Include'
    romsincludepath = os.path.join(code_path,romsinclude)
    os.chdir(romsincludepath)
    shutil.copy2(includefile,project_path)

    base_bashfile   ='coawst.bash' 
    base_runfile    ='run_nemo'
    case_subpath    =project_path # this is different for case within a subfolder
    couple_flag     ='1way'
    ntilex          = 4
    ntiley          = 2
    tot_nproc       = ntilex*ntiley
    nodes           = 1    # for NEMO ppn=8 
    execute         = 'coawstM'
    logfile         = 'log.out_' + case_name
    buildfile       = 'Build.txt'

    os.chdir(code_path)
    """ Make local copies for each case """
    bashfile  = base_bashfile + "_" + case_name 
    shutil.copy2(base_bashfile,bashfile)
      
    runfile   = base_runfile + "_" + case_name
    shutil.copy2(base_runfile,runfile)
 
    util.edit_bashfile(bashfile,case_name,code_path,project_path)
 
    print "------------------------------------------"
    print "Compiling:", case_name,"case"
    os.system('./%(bashfile)s >>Build.txt 2>&1' %locals() )

    util.edit_jobscript(runfile,oceaninfile,case_name,project_str,code_path,\
                         tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_oceaninfile(oceaninfile,ntilex,ntiley)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing test :", case_name
    p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE) 
    stdout,stderr=p.communicate()

#check every ten mins
    stdout_case=stdout
    util.check_queue(stdout_case)

#if it is done it will get out of loop
    
#   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile, \
                        execute,stdout,logfile)
Example #9
0
def regress_sandy(code_path):
    case_name       ='Sandy'
    base_bashfile   ='coawst.bash' 
    base_runfile    ='run_nemo'
    oceaninfile     ='ocean_%s.in' % (case_name.lower())
    couplefile      = 'coupling_%s.in'  % (case_name.lower())
    project_str     ='Projects'+'/'+case_name
    project_path    =os.path.join(code_path,project_str)
    couple_flag     ='3way'
    ntilex          = 2
    ntiley          = 2
    nocn            = ntilex*ntiley  
    nwav            = 2 
    nprocx_atm      = 2
    nprocy_atm      = 1
    natm            = nprocx_atm*nprocy_atm
    tot_nproc       = nocn+nwav+natm 
    nodes           = 1                    # for NEMO ppn=8
    execute         = 'coawstM'
    logfile         = 'log.out_' + case_name 
    buildfile       = 'Build.txt'

    os.chdir(project_path)
    util.edit_wrfinfile('namelist.input',nprocx_atm,nprocy_atm)
    wrffiles=['namelist.input','wrfbdy_d01','wrfinput_d01','wrfinput_d02', \
              'wrflowinp_d01','wrflowinp_d02'] 
    for filename in wrffiles:
        shutil.copy(filename,code_path)
      
    os.chdir(code_path)

    """ Make local copies for each case """
    bashfile  = base_bashfile + "_" + case_name 
    shutil.copy2(base_bashfile,bashfile)
      
    runfile   = base_runfile + "_" + case_name
    shutil.copy2(base_runfile,runfile)
 
    util.edit_bashfile(bashfile,case_name,code_path,project_path)
 
    print "------------------------------------------"
    print " Make clean WRF:", case_name, "case"
    """ enter the WRF folder """
    WRF_path=os.path.join(code_path,'WRF')
    os.chdir(WRF_path)
    os.system('./clean -a  >>WRF_clean.txt 2>&1') 

    """ Change back to code_path """
    os.chdir(code_path)

    """ copy the configure file in WRF folder """ 
    src_wrf_conf = os.path.abspath('../coawst_regress_baseline/WRF_config_file/configure.wrf')
    dest2=os.path.join(code_path,'WRF')
    shutil.copy(src_wrf_conf,dest2)

    print "------------------------------------------"
    print "Compiling:", case_name,"case"
    os.system('./%(bashfile)s  >>Build.txt 2>&1' %locals() )

    util.edit_jobscript(runfile,couplefile,case_name,project_str,code_path,\
                        tot_nproc,nodes)

    os.chdir(project_path)
    util.edit_oceaninfile(oceaninfile,ntilex,ntiley)
    util.edit_couplefile(couplefile,natm,nwav,nocn,couple_flag)

    os.chdir(code_path)
    print "------------------------------------------"
    print "Executing case:", case_name
    p=subprocess.Popen("qsub %(runfile)s" %locals(),shell=True,stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE) 
    stdout,stderr=p.communicate()

#check every ten mins
    stdout_case=stdout
    util.check_queue(stdout_case)

#   Moving output files to each projects folder
    util.move_casefiles(project_path,case_name,bashfile,runfile,buildfile,\
                        execute,stdout,logfile)

#   Remove WRF files from the code path 
    for filename in wrffiles:
        os.remove(filename)