#!/usr/bin/perl -w # SCMD/cgi-bin/CMD: program to answer *and generate* stars # number of stars form (version 2) use strict; # enforce variable declarations and quoting use CGI qw(:standard); sub bail{ my $error ="@_"; print h1("Unexpected Error"), p($error), end_html; die $error; } my $dataurl="http://www.astro.yale.edu/murphy/SCMD/cgi-bin/table/SCMD.dat"; my $BVurl="http://www.astro.yale.edu/murphy/SCMD/cgi-bin/table/SCMD_BV.ps"; my $VIurl="http://www.astro.yale.edu/murphy/SCMD/cgi-bin/table/SCMD_VI.ps"; my $defurl="http://www.astro.yale.edu/murphy/SCMD/cgi-bin/params/def.html"; print header, start_html("Synthetic CMD"), h1("Synthetic CMD v2.0"); print hr(); print p("click here for : parameter definitions"); if (param()){ # the form has already been filled out my $alpha = param("Alpha enrichment"); my $Z = param("Metallicity"); my $Age = param("Age"); my $N = param("Number"); my $IMF_s = param("IMF slope"); my $IMF_u = param("IMF upper limit"); my $IMF_l = param("IMF lower limit"); my $ISEED = param("ISEED"); my $BF = param("Binary Fraction"); my $q = param("qmass"); if ($N <= 0 || $N >100000) {bail("Number of stars must be greater than 0 and less a maximum of 100000. $!");} #remove older temporary files system("\\rm params/SCMD.IN"); system("\\rm params/YYISO.IN"); system("\\rm code/junk*"); system("\\rm code/logfile"); open(PARAMS,">params/SCMD.IN") || bail("Cannot open 'SCMD.IN' for reading $!"); print PARAMS "$N !nstar\n$IMF_s\d0 !IMF slope\n$IMF_u\d0 !IMF upper limit\n$IMF_l\d0 !IMF lower limit\n$ISEED !RN ISEED\n$BF !binary fraction\n$q\d0 !qmass\n"; close PARAMS or warn $!; #System calls to update the YY.nml file for interpolation routine system("sed 's/AFe_INIT/$alpha/g' code/YY.nml_INIT > code/junk1.nml"); system("sed 's/Z_INIT/$Z/g' code/junk1.nml > code/junk2.nml"); system("sed 's/Age_INIT/$Age/g' code/junk2.nml > code/junk3.nml"); system("mv code/junk3.nml code/YY.nml"); print p("Your input paramaters were:"); print("alpha=$alpha, Z=$Z, Age=$Age, N=$N, IMF=$IMF_l - $IMF_u with slope $IMF_s, ISEED=$ISEED, Binary Fraction=$BF, q=$q"); print p("Please wait a moment while your syntetic CMD is created."); #System calls to remove older plots and data tables system("\\rm table/SCMD.dat"); system("\\rm table/SCMD_BV.ps"); system("\\rm table/SCMD_VI.ps"); #System calls to Fortran codes and plotting code system("code/YYmix2.out > code/logfile"); system("code/SCMD.out"); system("gnuplot code/SCMD.gnu"); print p("click here to : get your SCMD data"); print p("click here to get a plot of your: (B-V) SCMD or (V-I) SCMD"); } else { # first time through, so present clear form print hr(); # hr() emits html horizontal rule: