#! /usr/bin/perl ############################################################################ # zsolt.szabo@noaa.gov # # use: upa [model name] [cycle] [size] # # model name={gfs or nam} # # cycle={0} # # size={l} # ############################################################################ $DEBUG=1; sub init_defs; sub do_main_hdr; sub gen_body; sub no_data_found; init_defs; # initialize default variables, etc. # Here we build the web page and write it out to $ofile (which is # defined above as $modhtml/model_[size].shtml) 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 upa 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 } 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: upa_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"; } #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/model_${siz}.shtml"; $ofile="$htmltmp/upa.shtml"; #get the path for image directory #$image_dir = "$basep/$model/$cycle/images"; $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 ###MAS $htmdir="${region}/${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";
| Mandatory Level (mb) |
|---|