<?php
include("mm5_p1.tpl");
include("mm5_p2.tpl");
?>
<script language="javascript">
function OnlineHelp(index){
HelpAry=["Map projection: three types are available:\n- Lambert conformal\n- Polar stereographic\n- Mercator",
"Longitude Upper-Left Corner",
"Latitude Upper-Left Corner",
"Longitude Lower-Right Corner",
"Latitude Lower-Right Corner",
"The grid distance for each of the domains in km.",
"The mother domain's ID number for each of the domains.\nFor the coarse domain, always set NUMNC=1.",
"The source terrain height and land-use data type for each of the domains:\n1=one degree;\n2=30 min.;\n3=10min.;\n4=5 min.;\n5=2 min.;\n6=30 sec.",
"starting time in minutes for each domain",
"ending time in minutes for each domain.",
"To indicate the nest type: 1=one way nest; 2=two way nest.",
"level of nest for each domain.\n0-for domain\n1-default valid values are 0-3",
"Boundary condition options: \n= 0, fixed,\n= 2, time-dependent (recommend all 2-way nests use this option),\n= 3,relaxation inflow/outflow.",
"used for bucket moisture scheme.\n= 0, do not use bucket scheme.\n= 1, use bucket scheme, and soil moisture is initialized with moisture availability values in LANDUSE.TBL.\n= 2, use bucket scheme, and soil moisture is initialized with soil moisture fields from MMINPUT files.",
"= 1, snow cover effects (requires input SNOWC field from REGRID)\n= 2, snow-cover prediction (requires input WEASD field from REGRID, and use of IMPHYS = 4,5, and 7)",
"= 1, compute surface heat and moisture fluxes;\n=0, no fluxes.",
"= 1, ground temperature predicted;\n= 3, constant ground temperature.",
"= 1, use 13 land-use categories;\n= 0, use only 2 (land/water) categories.",
"= 1, consider cloud effects on surface radiation when FRAD=0,\n1 ; consider clouds in both surface and atmospheric radiation when FRAD=2,3,4;\n= 0, do not consider cloud effect on radiation;\n= 2, (IFRAD=3 only) radiation interacts with RH-derived cloud fraction only.\n",
"= 1, normal evaporative cooling;\n= 0, no evaporative effects; \n= -1, no precip evaporative cooling, (for IMPHYS=3,4, and 5).",
"= 1, if this domain is active when restart;\n= 0, if this domain is inactive.",
"= 1, for initializing a nest from the nest input file, usually at model starting time;\n= 0, for interpolating to a nest from parent mesh, usually during model integration;\n= 2, for initializing domain with high resolution terrain, usually during model integration.",
"click here for add this domain."];
document.forms[0].TextHelp.value=HelpAry[index];
}
function popUps(URL,sw,sh) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+sw+",height="+sh+"');");
}
function Next(){
if (document.forms[0].EdtHid.value==0){
alert("You must set at least one domain!");
document.forms[0].seemform.value="NoY";
}
//else document.forms[0].action="mm5_p2.php";
}
</script>
<?php
function ReloadPage($RecNo,$user){
include("mm5_p1.tpl");
print $top;
$RecNo++;
$HidSec="<input type=\"hidden\" value=\"$RecNo\" name=\"EdtHid\">";
print $HidSec;
$fp=fopen("/mm5/files/user_folders/$user/domain.opt","r");
$i=1;
while(!feof($fp)){
$line=fgets($fp,1024);
if($line=="")break;
$fields=split(",",$line);
if($i%2!=1)$rowcolor="FFB4B4";
else $rowcolor="FFFFDD";
$row="<tr>
<td width=\"54\" style=\"font-weight:color: black; border-left-style: none; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[0]</font><!--mstheme--></font></td>
<td width=\"314\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[1],$fields[2]</font><!--mstheme--></font></td>
<td width=\"284\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[3],$fields[4]</font><!--mstheme--></font></td>
<td width=\"74\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[5]</font><!--mstheme--></font></td>
<td width=\"143\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[6]</font><!--mstheme--></font></td>
<td width=\"136\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[7]</font><!--mstheme--></font></td>
<td width=\"558\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[8]</font><!--mstheme--></font></td>
<td width=\"131\" style=\"font-weight: color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font face=\"Arial\" size=\"1\">$fields[9]</font><!--mstheme--></font></td>
<td width=\"137\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font face=\"Arial\" size=\"1\">$fields[10]</font><!--mstheme--></font></td>
<td width=\"280\" style=\"font-weight:color: black; border-left: .75pt solid black; border-right-style: none; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\" align=\"center\"><!--mstheme--><font face=\"Book Antiqua, Times New Roman, Times\">
<font size=\"1\" face=\"Arial\">$fields[11]</font><!--mstheme--></font></td>
</tr>";
print $row;
$i++;
}
fclose($fp);
print $bottom;
print $HidSec;
print $nextpart;
}
//main
if( ($seemform!="y") && ($step!=2)){
$RecNo=0;
$HidSec="<input type=\"hidden\" value=\"$RecNo\" name=\"EdtHid\">";
print $ftop;
print $HidSec;
print $fbottom;
}
else if($step==1){
$ErrorFlag=0;
$ErrorAry=array();
$cx1=$EdtLonUL;
$cy1=$EdtLatUL;
$cx2=$EdtLonLR;
$cy2=$EdtLatLR;
$DIS=$EdtGrid;
$MumId=$EdtMumDom;
$exist="YES";
//check for empty field
if(($DIS==0)or($cx1=="")or($cx2=="")or($cy1=="")or($cy2=="")or
($EdtMumDom=="")or($EdtLevelNest=="")or($EdtDomInt=="")or
($EdtDomEnd=="")or($CmbBoxIboudy=="")or
($CmbBoxImoiav=="")or($CmbBoxIfsnow=="")or($CmbBoxIsfflx=="")or($CmbBoxItgflg=="")or
($CmbBoxIsfpar=="")or($CmbBoxIcloud=="")or($CmbBoxIevap=="")or($CmbBoxIoverw=="")or
($CmbBoxIactiv=="")){
$ErrorFlag=1;
array_push($ErrorAry,"Some fields are empty.");
}
if( (ereg("[^0-9.]",$EdtLonUL))or(ereg("[^0-9.]",$EdtLatUL))or(ereg("[^0-9.]",$EdtLonLR))or
(ereg("[^0-9.]",$EdtLatLR))or(ereg("[^0-9.]",$EdtGrid)) or(ereg("[^0-9.]",$EdtMumDom))or
(ereg("[^0-9.]",$EdtLevelNest))or(ereg("[^0-9.]",$EdtDomInt))or(ereg("[^0-9.]",$EdtDomEnd))or
(ereg("[^0-9.]",$CmbBoxIboudy))or(ereg("[^0-9.]",$CmbBoxImoiav))or(ereg("[^0-9.]",$CmbBoxIfsnow))or
(ereg("[^0-9.]",$CmbBoxIsfflx))or(ereg("[^0-9.]",$CmbBoxItgflg))or(ereg("[^0-9.]",$CmbBoxIsfpar))or
(ereg("[^0-9.]",$CmbBoxIcloud))or(ereg("[^0-9.]",$CmbBoxIevap))or(ereg("[^0-9.]",$CmbBoxIoverw))or
(ereg("[^0-9.]",$CmbBoxIactiv)) ){$ErrorFlag=1;array_push($ErrorAry,"All fields must be digit.");}
if(($CmbBoxIboudy!=0)and($CmbBoxIboudy!=2)and($CmbBoxIboudy!=3)){$ErrorFlag=1;array_push($ErrorAry,"IBOUDY is invalid.");}
if(($CmbBoxImoiav!=0)and($CmbBoxImoiav!=1)and($CmbBoxImoiav!=2)){$ErrorFlag=1;array_push($ErrorAry,"IMOIAV is invalid.");}
if(($CmbBoxIfsnow!=0)and($CmbBoxIfsnow!=1)and($CmbBoxIfsnow!=2)){$ErrorFlag=1;array_push($ErrorAry,"IFSNOW is invalid.");}
if(($CmbBoxIsfflx!=0)and($CmbBoxIsfflx!=1)){$ErrorFlag=1;array_push($ErrorAry,"ISFFLX is invalid.");}
if(($CmbBoxItgflg!=1)and($CmbBoxItgflg!=3)){$ErrorFlag=1;array_push($ErrorAry,"ITGFLG is invalid.");}
if(($CmbBoxIsfpar!=0)and($CmbBoxIsfpar!=1)){$ErrorFlag=1;array_push($ErrorAry,"ISFPAR is invalid.");}
if(($CmbBoxIcloud!=0)and($CmbBoxIcloud!=1)){$ErrorFlag=1;array_push($ErrorAry,"ICLOUD is invalid.");}
if(($CmbBoxIevap!=-1)and($CmbBoxIevap!=0)and($CmbBoxIevap!=1)){$ErrorFlag=1;array_push($ErrorAry,"IEVAP is invalid.");}
if(($CmbBoxIoverw!=0)and($CmbBoxIoverw!=1)and($CmbBoxIoverw!=2)){$ErrorFlag=1;array_push($ErrorAry,"IOVERW is invalid.");}
if(($CmbBoxIactiv!=0)and($CmbBoxIactiv!=1)){$ErrorFlag=1;array_push($ErrorAry,"IACTIV is invalid.");}
if(($cx1>=$cx2)or($cy1<=$cy2)){$ErrorFlag=1;array_push($ErrorAry,"Domain coordinates are wrong.");}
if(($CmbBoxIevap==-1)and($CmbBoxImphys!=3)and($CmbBoxImphys!=4)and($CmbBoxImphys!=5)){$ErrorFlag=1;array_push($ErrorAry,"if IEVAP=-1 then IMPHYS must be 3 or 4 or 5");}
if($CmbBoxNstTyp=="Two way nest"){
$abs=abs($cy1-$cy2);
$N=$abs*111/$DIS;
$N=(round($N)-1)/3;
if($N-round($N)!=0){
$ErrorFlag=1;
array_push($ErrorAry,"(Number of nest grid point[Latitude]-1)/3 is not integer.");
}
$abs=abs($cx1-$cx2);
$N=$abs*111/$DIS;
$N=(round($N)-1)/3;
if($N-round($N)!=0){
$ErrorFlag=1;
array_push($ErrorAry,"(Number of nest grid point[Longitude]-1)/3 is not integer.");
}
}//if
//check for mother domain
if($EdtHid==0){
$DomainNo=1;
$MumId=1;
$exist="NO";
$chk1=1;
$chk4=1;
}
else{//this domain in not main
$fp=fopen("/mm5/files/user_folders/$user/domain.opt","r");
$DomainNo=1;
for($i=0;$i<$EdtHid;$i++){
$line=fgets($fp,1024);
if($line=="")break;
$fields=split(",",$line);
$mx1=$fields[1];
$my1=$fields[2];
$mx2=$fields[3];
$my2=$fields[4];
if($fields[0]==$MumId){// her\his mother
if(($cx1<=$mx1)or($cx2>=$mx2)or
($cy1>=$my1)or($cy2<=$my2)){$ErrorFlag=1;array_push($ErrorAry,"The Child domain is out of mother domain's ranges.");}
$MDIS=$fields[5];
$chk1=abs($my2-$cy2)*111/$MDIS;
$chk2=abs($mx2-$cx2)*111/$MDIS;
$chk3=abs($my1-$cy1)*111/$MDIS;
$chk4=abs($mx1-$cx1)*111/$MDIS;
if(($chk1<=5)or($chk2<=5)or($chk3<=5)or($chk4<=5))
{$ErrorFlag=1;array_push($ErrorAry,"A nest must be at least 5 coarse grid points away from the coarse domain boundary.");}
}
else if($fields[6]==$MumId){// her\his sibling
if((($mx1>=$cx1)and($mx1<=$cx2))or
(($mx2>=$cx1)and($mx2<=$cx2))or
(($my1<=$cy1)and($my1>=$cy2))or
(($my2<=$cy1)and($my2>=$$cy2))){$ErrorFlag=1;array_push($ErrorAry,"TERRAIN program cannot be used to generate overlapping nests.");}
}
$DomainNo++;
}
fclose($fp);
if(($MumId<1)or($MumId>=$DomainNo)){$ErrorFlag=1;array_push($ErrorAry,"This Mother Doamin number not exist.");}
}
if($ErrorFlag!=1){
$rec=$DomainNo.",".$cx1.",".$cy1.",".$cx2.",".$cy2.",".$DIS.",".$MumId.",".
$CmbBoxDataRes.",".$CmbBoxNstTyp.",".$EdtDomInt.",".$EdtDomEnd.",".
$EdtLevelNest.",".$CmbBoxIboudy.",".$CmbBoxImoiav.",".
$CmbBoxIfsnow.",".$CmbBoxIsfflx.",".$CmbBoxItgflg.",".$CmbBoxIsfpar.",".$CmbBoxIcloud.",".
$CmbBoxIevap.",".$CmbBoxIoverw.",".$CmbBoxIactiv.",".$CmbBoxMapPrj.",".$chk1.",".$chk4.",".
$CmbBoxImphys.",".$CmbBoxIcupa.",".$CmbBoxIbltyp.",".$CmbBoxFrad.",".$CmbBoxIshallo.","."\n";
if($exist=="NO"){
$fp = fopen ("/mm5/files/user_folders/$user/domain.opt", "w+");
fwrite ($fp, $rec);
fclose ($fp);
}
else{
$fps = fopen ("/mm5/files/user_folders/$user/domain.opt", "r+");
$fpd = fopen ("/mm5/files/user_folders/$user/domain.tmp", "w+");
for($i=0;$i<$EdtHid;$i++){
$line=fgets($fps,1024);
fwrite($fpd,$line);
}
fseek($fpd,0,SEEK_END);
fwrite($fpd,$rec);
fclose($fpd);
fclose($fps);
$fps = fopen ("/mm5/files/user_folders/$user/domain.tmp", "r");
$fpd = fopen ("/mm5/files/user_folders/$user/domain.opt", "w+");
while(!feof($fps)){
$line=fgets($fps,1024);
fwrite($fpd,$line);
}
fclose($fpd);
fclose($fps);
}
ReloadPage($EdtHid,$user);
}
else{//print Error
print "<h2>The following errors has been occured...</h2>";
for($i=0;$i<sizeof($ErrorAry);$i++)print "<p><font color=red><b>§</b> $ErrorAry[$i]</font></p>";
print "<input type=\"submit\" value=\"Back\" name=\"btnBack\" onclick=\"javascript:history.back(1)\">";
}
}//else
?>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<!------------------------------------------------------------------------------------------------------------>
<script language="javascript">
function OnlineHelp2(index){
var HelpAry=["frequency in minutes of radiation calculations\n(surface and atmospheric)",
"fake-dry run\n0=no latent heating\n1=for IMPHYS=2,3,4,5,6,7\n (requires ICUPA = 1)",
"=1,for moist vertical diffusion in clouds \n(requires IMPHYS>2, and IBLTYP=2 or 5)\n\n=0, vertical diffusion is dry",
"=0, vertical moisture advection uses log interpolation (old method).\n\n=1, vertical moisture advection uses linear interpolation (affects all moisture variables).",
"=0, vertical temperature advection uses log interpolation (old method).\n\n=1, vertical temperature advection uses linear interpolation.",
"=0, temperature advection and adiabatic term use temperature (old method).\n\n=1, temperature advection and adiabatic term use potential temperature.",
"=1, for diffusion using perturbation temperature in NH model.\n\n=0, not using this function (new in V2).",
"=1, for full 3D Coriolis force (requires INHYD=1).\n\n=0, for traditional approximation.",
"=1, for upper radiative boundary condition (NH run only).\n\n=0, rigid upper boundary in nonhydrostatic runs.",
"roughness length over land (m)\n(if ISFPAR=0).",
"roughness length over water (m)\n(if ISFPAR=0).",
"albedo over land (if ISFPAR=0).",
"thermal inertia of land\n(cal-1 cm-2 K-1 s-0.5, if ISFPAR=0).",
"moisture availability over land\n(if ISFPAR=0).",
"non-convective precip saturation criterior (fraction £ 1 for IMPHYS=1)."];
document.forms[0].TextHelp.value=HelpAry[index];
}
</script>
<!--*******************************************************************************************************-->
<?php
function Java(){
print "<script language=\"javascript\">
function WhenDateSelect(mother,daughter){";
$fp=fopen("/mm5/GLOBAL/AVN/avn_dates","r");
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
$line=str_replace("/","",$line);
print "var D$line=[";
$fpn=fopen("/mm5/GLOBAL/AVN/$line/hours","r");
$hour=fgets($fpn,1024);
$hour=str_replace("\n","",$hour);
print "\"$hour\"";
while( !feof($fpn) ){
$hour=fgets($fpn,1024);
if($hour=="")break;
print ",";
$hour=str_replace("\n","",$hour);
print "\"$hour\"";
}
print "];";
fclose($fpn);
}
print "var DatesSTR=[";
$fp=fopen("/mm5/GLOBAL/AVN/avn_dates","r");
$line=fgets($fp,1024);
$line=str_replace("\n","",$line);
$line=str_replace("/","",$line);
print "\"D$line\"";
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
print ",";
$line=str_replace("\n","",$line);
$line=str_replace("/","",$line);
print "\"D$line\"";
}
print "];";
fclose($fp);
print "var DatesTWO=[";
$fp=fopen("/mm5/GLOBAL/AVN/avn_dates","r");
$line=fgets($fp,1024);
$line=str_replace("\n","",$line);
$line=str_replace("/","",$line);
print "D$line";
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
print ",";
$line=str_replace("\n","",$line);
$line=str_replace("/","",$line);
print "D$line";
}
print "];";
fclose($fp);
print "removeOptions(daughter);
var itemindex=document.forms[0].elements[mother].selectedIndex;
var i=0;
while(i<DatesTWO[itemindex].length){
addOption(daughter,DatesTWO[itemindex][i],\"item\"+i);
i++;
}
};";
print "function removeOptions(daughter){
while(document.forms[0].elements[daughter].length != 0)
document.forms[0].elements[daughter].remove(0);
}
function addOption(daughter,text, value){
var oOption = document.createElement(\"OPTION\");
oOption.text=text;
oOption.value=text;
document.forms[0].elements[daughter].add(oOption);
};";
print "</script>";
}
?>
<!--*******************************************************************************************************-->
<?php
//------------------MM5---------------------
/* function Reload($top4,$mid41,$mid42,$bottom4,$user){
print $top4;
print "<select size=\"1\" name=\"CmbBoxDomain\">";
$fp=fopen("/mm5/files/user_folders/$user/domain.opt", "r");
$no=0;
while(!feof($fp)){fgets($fp,1024);$no++;}
fclose($fp);
for($i=1;$i<$no;$i++)
print "<option>Domain $i</option>";
print "</select> ";
print $mid41;
if(file_exists("/mm5/files/user_folders/$user/outconf.opt"))
{
$fp1=fopen("/mm5/files/user_folders/$user/outconf.opt","r");
$i=1;
while(!feof($fp1)){
$line=fgets($fp1,1024);
if($line=="")break;
$fields=split("[|]",$line);
if($i%2!=1)$rowcolor="FFB4B4";
else $rowcolor="FFFFDD";
$row="<tr>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[0]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[1]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[2]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[3]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>0</b></td>
</tr>";
print $row;
$i++;
}
fclose($fp1);
}
print $mid42;
if(file_exists("/mm5/files/user_folders/$user/outdom.opt"))
{
$fp2=fopen("/mm5/files/user_folders/$user/outdom.opt","r");
$i=1;
while(!feof($fp2)){
$line=fgets($fp2,1024);
if($line=="")break;
$fields=split("[|,]",$line);
if($i%2!=1)$rowcolor="FFB4B4";
else $rowcolor="FFFFDD";
$row="
<tr>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[0]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[1]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[2]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>A</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[4]</b></td>
<td width=\"20%\" style=\"font-weight: normal; color: black; border-left-style: none; border-right: .75pt solid black; border-top-style: none; border-bottom: .75pt solid black; background-color: $rowcolor\">
<p align=\"center\"><b>$fields[5]</b></td>
</tr>";
print $row;
$i++;
}
fclose($fp2);
}
print $bottom4;
} */
///******************************************
if( ($seem!="y") && ($step==2) ){
if($tmpname==""){
$fps = fopen ("/mm5/files/user_folders/$user/domain.opt", "r+");
$fpd = fopen ("/mm5/files/user_folders/$user/domain.tmp", "w+");
for($i=0;$i<$EdtHid;$i++){
$line=fgets($fps,1024);
fwrite($fpd,$line);
}
fseek($fpd,0,SEEK_END);
fwrite($fpd,$rec);
fclose($fpd);
fclose($fps);
$fps = fopen ("/mm5/files/user_folders/$user/domain.tmp", "r");
$fpd = fopen ("/mm5/files/user_folders/$user/domain.opt", "w+");
while(!feof($fps)){
$line=fgets($fps,1024);
fwrite($fpd,$line);
}
fclose($fpd);
fclose($fps);
}
//selected a temlplate
if($tmpname!="")
copy("/mm5/files/template/$resolution/$tmpname","/mm5/files/user_folders/$user/domain.opt");
//....
java();
print $body2_part1;
$fp=fopen("/mm5/GLOBAL/AVN/avn_dates","r");
$i=0;
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
if($i==0)$first=$line;
$i++;
print "<option>$line</option>";
}
fclose($fp);
print "</select>
Start Hour<select name=\"CmbBoxSHour\" size=\"1\">";
$first=str_replace("/","",$first);
$fp=fopen("/mm5/GLOBAL/AVN/$first/hours","r");
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
print "<option>$line</option>";
}
fclose($fp);
print "</select><br>
<br>
End Date <select size=\"1\" name=\"CmbBoxEDate\" onchange=\"WhenDateSelect(4,5)\">";
$fp=fopen("/mm5/GLOBAL/AVN/avn_dates","r");
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
print "<option>$line</option>";
}
fclose($fp);
print "</select>
End Hour <select name=\"CmbBoxEHour\" size=\"1\">" ;
$fp=fopen("/mm5/GLOBAL/AVN/$first/hours","r");
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
print "<option>$line</option>";
}
fclose($fp);
print "</select> ";
print $body2_part3;
}
//------------------------------------------
else if($step==2) switch($formtype){
case 2:$param=$CmbBoxSDate.",".$CmbBoxSHour.",".$CmbBoxEDate.",".$CmbBoxEHour.",".$EdtForcast.",".$EdtStep.",".$CmbBoxGlobal.",".$EdtInterval.",".$EdtTapfrq.",".$EdtSavfrq;
CheckP2($param,$body3,$user);
break;
case 3:$param=$EdtRadfrq.",".$CmbBoxIfdry.",".$CmbBoxImvdif.",".$CmbBoxIvqadv.",".$CmbBoxIvtadv.",".$CmbBoxIthadv.",".$CmbBoxItpdif.",".
$CmbBoxIcor3d.",".$CmbBoxIfupr.",".$EdtZzlnd.",".$EdtZzwtr.",".$EdtAlblnd.",".$EdtThinld.",".$EdtXmava.",".$EdtConf.",".$EdtRunName;
CheckP3($param,$top4,$mid41,$mid42,$bottom4,$user);
break;
}//end switch
//**************************************************
function CheckP2($line,$body3,$user){
$localpath="/mm5/LOCAL/";//local data path
$globalpath="/mm5/GLOBAL/";//global data path
$ErrorFlag=0;
$ErrorAry=array();
$fields=split(",",$line);
if(($fields[8]>$fields[4])or($fields[9]>$fields[4])){$ErrorFlag=1;array_push($ErrorAry,"TAPFRQ and SAVFRQ must be lower than Forecating time.");}
if(($fields[8]*60)%$fields[5]!=0){$ErrorFlag=1;array_push($ErrorAry,"TAPFRQ must be multiple of Time Step.");}
if($fields[8]==0){$ErrorFlag=1;array_push($ErrorAry,"TAPFRQ must be greater than Zero.");}
//fields[0]=strat date ,fields[1]=strat hour ,fields[2]=end date ,fields[3]=end hour
//fields[4]=forecast ,fields[5]=time step ,fields[6]=global model ,fields[7]=time interval
for($i=0;$i<sizeof($fields);$i++)
if($fields[$i]==""){$ErrorFlag=1;array_push($ErrorAry,"Some $i fields are empty.");break;}
for($i=1;$i<sizeof($fields);$i++){
if (($i!=2)and($i!=6))
if(ereg("[^0-9.]",$fields[$i])){$ErrorFlag=1;array_push($ErrorAry,"All fields must be digit.");break;}
}
if($fields[5]>=$fields[4]*60){$ErrorFlag=1;array_push($ErrorAry,"Time Step must be lower than Forecasting time.");}
$start=split("[/.-]",$fields[0]);//start[0]=day , start[1]=month ,start[2]=year
$GlobalDataPath=$globalpath.$fields[6]."/Tmp";
if(!is_dir($GlobalDataPath)){$ErrorFlag=1;array_push($ErrorAry,"Global data not found.");}
/* $day=$start[0];
$month=$start[1];
$year=$start[2];
$PathAry=array();//save all observation file path
$end=split("[/.-]",$fields[2]);
$clock=$fields[1];
while(($day!=$end[0])or($month!=$end[1])or($year!=$end[2])or($clock!=$fields[3])){
// print "$day--$end[0]#$month--$end[1]#$year--$end[2]#$fields[1]--$fiel
$path=$localpath.$year.$month.$day;
$sw=0;
if(!is_dir($path)){$ErrorFlag=1;array_push($ErrorAry,"Local data not found.");break;}
if(($day==$end[0])and($month==$end[1])and($year==$end[2]))$sw=1;
while((($clock<24)and($sw==0))or(($clock<=$fields[3])and($sw==1))){
if($clock<10)$clock="0".$clock;
$path1=$path."/".$clock;
if(!is_file($path1)){$ErrorFlag=1;array_push($ErrorAry,"Observation file at $clock not found.");}
else array_push($PathAry,$path1);
$clock+=$fields[7];
}
if($sw==1)break;
if($clock==24)$clock=0;
$day++;
switch($month){
case 2:$max=28;break;
case 4:
case 6:
case 9:
case 11:$max=30;break;
default:$max=31;
}
if($day>$max){$day=1;$month++;}
if($month>12){$month=1;$year++;}
}//end while*/
/*@check for start date <= end date*/
$sdate=split("[/.-]",$fields[0]);
$sday=$sdate[2]; $smonth=$sdate[1]; $syear=$sdate[0];
$shour=$fields[1];
$edate=split("[/.-]",$fields[2]);
$eday=$edate[2]; $emonth=$edate[1]; $eyear=$edate[0];
$ehour=$fields[3];
if( ($syear>$eyear) or ( ($syear==$eyear) and ($smonth>$emonth) ) or
( ($syear==$eyear) and ($smonth==$emonth) and ($sday>$eday)) or
( ($syear==$eyear) and ($smonth==$emonth) and ($sday>$eday) and ($shour>$ehour)) )
{$ErrorFlag=1;array_push($ErrorAry,"Start Date and Start Hour must lower than End Date and End Hour.");}
/**/
if($ErrorFlag!=1){
$fp=fopen("/mm5/files/user_folders/$user/time.opt", "w+");
fwrite($fp,$line);
fclose ($fp);
//print mm5 form
print $body3;
}
else{//print error
print "<h2>The following errors has been occured...</h2>";
for($i=0;$i<sizeof($ErrorAry);$i++)print "<p><font color=red><b>§</b> $ErrorAry[$i]</font></p>";
print "<input type=\"submit\" value=\"Back\" name=\"btnBack\" onclick=\"javascript:history.back(1)\">";
}
}//end function
function CheckP3($line,$top,$mid1,$mid2,$bottom,$user){
$ErrorFlag=0;
$ErrorAry=array();
$tmp=split(",",$line);
for($i=0;$i<sizeof($tmp)-1;$i++){
if($tmp[$i]==""){$ErrorFlag=1;array_push($ErrorAry,"Some fields are empty.");break;}
if(ereg("[^0-9.]",$tmp[$i])){$ErrorFlag=1;array_push($ErrorAry,"All fields must be digit.");break;}
}
$run_name=str_replace("\n","",$tmp[15]);
if(ereg("[?!#$%^&*()=:+,;><@|~`\"\' ]",$tmp[15])){
$ErrorFlag=1;
array_push($ErrorAry,"$run_name is invalid , please correct it.");
}
$fp=fopen("/mm5/files/user_folders/$user/time.opt","r");
$rec=fgets($fp,1024);
fclose($fp);
$field_ary=split(",",$rec);
$date_ary=split("/",$field_ary[0]);
$s_date=$date_ary[2]."_".$date_ary[1]."_".$date_ary[0];
if ( file_exists("/mm5/backup/$s_date/runs") ){
$fp=fopen("/mm5/backup/$s_date/runs","r");
while(!feof($fp)){
$rec=fgets($fp,1024);
$rec=str_replace("\n","",$rec);
if($rec==$run_name){$ErrorFlag=1;array_push($ErrorAry,"$run_name already exist , please change it.");break;};
}
fclose($fp);
}
if($ErrorFlag!=1){
$fp=fopen("/mm5/files/user_folders/$user/mm5.opt", "w+");
fwrite($fp,$line);
fclose($fp);
print "<script language=\"javascript\">
var parameters=\"toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizeable=0,height=600,width=800\";
runWindow=open(\"cgi/run.php?user=$user\",\"newDocument\",parameters);
window.close();
</script> ";
}
else{//print error
print "<h2>The following errors has been occured...</h2>";
for($i=0;$i<sizeof($ErrorAry);$i++)print "<p><font color=red><b>§</b> $ErrorAry[$i]</font></p>";
print "<input type=\"button\" value=\"Back\" name=\"btnBack\" onclick=\"javascript:history.back(1)\">";
}
}//end function
?>
</body>
</html>