#! /usr/bin/perl ############################################################################ # bhavana.rakesh@noaa.gov # # use: ww3_model_page [model name] [cycle] [size] # # model name={gfs} # # cycle={00,06,12,18} # # size={m} # ############################################################################ $DEBUG=1; sub init_defs; sub do_main_hdr; sub gen_body; sub no_data_found; sub create_index_pacatl_loop; sub create_pacatl_loop; sub create_pacatl_applet; sub create_loop_list; init_defs; # initialize default variables, etc. # Here we build the web page and write it out to $ofile (which is # defined within init_defs) open (MFF, ">${ofile}"); do_main_hdr; # print main html header #Check if image_dir is empty. If it is empty, build a no_data_found page #else build the default ww3 model page $image_dir ="$htmltmp/images/"; if($DEBUG>0){ print("IMAGE DIRECTORY = $image_dir\n"); } my @files = <$image_dir/*>; my $count = @files; if($count>0) { gen_body; # generate main page create_index_pacatl_loop; create_pacatl_loop; create_pacatl_applet; create_loop_list; } else { no_data_found; } exit 0; ############################################################################ ############################################################################ # Initial definitions and tests # Define some constants, make sure we have the right number and type of # arguments. sub init_defs { if ($#ARGV != 2) { die "use: ww3_model_page [model name] [cycle] [size]\n"; } # basep - the root directory, up to the location where the model dirs live # model - the name of the model (gfs,nam, etc.) # title - the title given for the table; it is derived from the model name # cycle - (00,06, etc.) # siz - three web pages are built, one for each size (s,m,l) if ($DEBUG > 0) { print"DATA = $ENV{DATA}\n"; print"BASEDIR = $ENV{BASEDIR}\n"; print"FIXgempak = $ENV{FIXgempak}\n"; print"REGION = $ENV{REGION}\n"; } if ($ENV{DATA}) { $data=$ENV{DATA}; } else { die "You must define environment variable DATA.\n"; } if ($ENV{BASEDIR}) { $basep=$ENV{BASEDIR}; } else { die "You must define environment variable BASEDIR.\n"; } if ($ENV{FIXgempak}) { $fixgem=$ENV{FIXgempak}; } else { die "You must define environment variable FIXgempak.\n"; } if ($ENV{REGION}) {$region=$ENV{REGION}; } else { die "You must define environment variable REGION.\n"; } if ($region =~ /namer/) { $regtitle="North America"; } elsif ($region =~ /npac/ ) { $regtitle="North Pacific"; } elsif ($region =~ /carib/ ) { $regtitle="Western North Atlantic"; } elsif ($region =~ /canada/ ) { $regtitle="Canada"; } elsif ($region =~ /alaska/ ) { $regtitle="Alaska"; } elsif ($region =~ /united/ ) { $regtitle="United States of America"; } elsif ($region =~ /mexico/ ) { $regtitle="Mexico"; } elsif ($region =~ /samer/ ) { $regtitle="South America"; } elsif ($region =~ /africa/ ) { $regtitle="Africa"; } elsif ($region =~ /pacatl/ ) { $regtitle="Atlantic-Pacific"; } #convert the region title to upper case to look up the graphics file for the html #$uc_regtitle = uc($regtitle); $basep="$basep/$region"; #if ($ENV{DEVELOP}) { $basep="$basep/temp"; } $model=@ARGV[0]; $title=uc $model; # title for table $cycle=@ARGV[1]; $htmltmp="$basep/$model/$cycle"; $siz=@ARGV[2]; # siz=image size (different pages created for each # image size: small, medium, large) if(DEBUG>0) { print"model = $model\n"; print"cycle = $cycle\n"; print"siz = $siz\n"; print"region = $region\n"; } if ($siz !~ /[sml]/) { die "Size must be [sml]\n"; } if ($cycle !~ /00|06|12|18/) { if ($model !~ "ruc" ) { die "cycle must be [00|06|12|18]\n"; } } $ofile="$htmltmp/ww3_m.shtml"; #get the path for image directory $image_dir ="$htmltmp/images/"; if($DEBUG>0) { print"image directory = $image_dir\n"; } if ($ENV{RELPATH}) {$hrf=$ENV{RELPATH}; } else { $hrf="/pmb/nw${envir}/analysis"; } # gifdir - location of the GIF files, based on model and cycle # htmdir - location of the html files # basep and gifdir together make up a complete path to the images of a # particular model/cycle $htmdir="/${model}/${cycle}"; $gifdir="${htmdir}/images"; $modhtms=$htmltmp; $modgifs="${basep}/${gifdir}"; return; } ############################################################################ ######################################################################### # Creating header for model html page sub do_main_hdr { print MFF <<"EOS"; NCEP WW3 Wind and Wave Heights EOS return; } ######################################################################### # Generate the content of the WW3 model page ######################################################################### sub gen_body { print MFF << "EOS2";

WW3 Wind and Wave Heights
${regtitle} ${cycle} UTC ${title}

  WW3 Wind and Wave Heights
  Loop
Initial 000
Day 1 006
012
018
024
Day 2 030
036
042
048
Day 3 054
060
066
072
Day 4 078
084
090
096
Day 5 102
108
114
120
Day 6 126
EOS2 return; } ################################################################ # Create index_pacatl_loop.shtml ################################################################# sub create_index_pacatl_loop { open (MFF1, ">${htmltmp}/index_pacatl_loop.shtml"); print MFF1 << "EOS3"; NCEP Model Analyses and Forecasts
NCEP Home > NCEP Central Operations > Production Management Branch > Model Analyses and Forecasts > NAM
Page last modified:
EOS3 return; } ################################################################## # Generate the content of the pacatl_loop.shtml page #################################################################### sub create_pacatl_loop { open (MFF2, ">${htmltmp}/pacatl_loop.shtml"); print MFF2 << "EOS4";
Wave graphics for Atlantic-Pacific Loop
EOS4 return; } ################################################################## # Generate the content of the pacatl_applet.shtml page #################################################################### sub create_pacatl_applet { open (MFF3, ">${htmltmp}/pacatl_applet.shtml"); print MFF3 << "EOS5";
Wave graphics for Atlantic_Pacific region(current to 126hrs)
EOS5 return; } ################################################################## # Generate the content of the loop_list page #################################################################### sub create_loop_list { use File::Path; mkpath "${htmltmp}/loop_lists/"; open (MFF4, ">${htmltmp}/loop_lists/loop.list"); print MFF4 << "EOS6"; images/wave_gw3_000m.gif images/wave_gw3_006m.gif images/wave_gw3_012m.gif images/wave_gw3_018m.gif images/wave_gw3_024m.gif images/wave_gw3_030m.gif images/wave_gw3_036m.gif images/wave_gw3_042m.gif images/wave_gw3_048m.gif images/wave_gw3_054m.gif images/wave_gw3_060m.gif images/wave_gw3_066m.gif images/wave_gw3_072m.gif images/wave_gw3_078m.gif images/wave_gw3_084m.gif images/wave_gw3_090m.gif images/wave_gw3_096m.gif images/wave_gw3_102m.gif images/wave_gw3_108m.gif images/wave_gw3_114m.gif images/wave_gw3_120m.gif images/wave_gw3_126m.gif EOS6 return; } ################################################################## # Generate the content of the no_data_found page #################################################################### sub no_data_found { print MFF << "EOS3";

No WW3 Wind and Wave Heights Forecasts Available For
${regtitle} ${cycle} UTC ${title}

EOS3 return; }