示例#1
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)
示例#2
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)