[OpenMadrigal-developers] Some patches to Madrigal system

William Rideout brideout at haystack.mit.edu
Tue Jul 1 12:24:48 EDT 2003


Christian,

It looks like you have a lot of good improvements here.  I'm leaving for
vacation today for two weeks, so I'll look at them more closely when I get
back.  In general I'll probably just insert most of the improvements as
is; and if not, I'll send a reply about possible modifications.

I look forward to working together in the future.

Bill

Bill Rideout
MIT Haystack Observatory
Email: brideout at haystack.mit.edu
Phone: 781 981-5624

On Tue, 1 Jul 2003, Christian [iso-8859-1] Häggström wrote:

> Hi all people on this list,
> 
> First I would like to thank Bill for the answers and explanation
> of why python is included.
> 
> I have build the Madrigal system for www.eiscat.com, and here follows
> all changes I have made to the code. The intention is that these fixes
> should be part of the next release, if they look fine in your eyes.
> 
> ==============================
> A problem with the CVS directory lying in the directories copied:
> 
> diff -u -r1.13 configureHtml
> --- configureHtml	8 Aug 2002 12:36:47 -0000	1.13
> +++ configureHtml	1 Jul 2003 07:16:17 -0000
> @@ -121,8 +121,8 @@
>  puts "Copying doc/*.gif to $madserverdocabs"
>  eval file copy -force [glob doc/*.gif] $madserverdocabs
>  
> -puts "Copying doc/icons/* to $madserverdocabs/icons"
> -eval file copy -force [glob icons/*] [file join $madserverdocabs icons]
> +puts "Copying icons/* to $madserverdocabs/icons"
> +eval file copy -force [glob icons/*.*] [file join $madserverdocabs icons]
>  
>  puts "Copying doc/madpyDoc to $madserverdocabs"
>  exec cp -r doc/madpyDoc $madserverdocabs
> 
> ==============================
> The infinite symbolic link MADROOT/experiments/experiments -> ../experiments
> is avoided with this patch chunk:
> 
> @@ -134,5 +134,4 @@
>  exec chmod 777 $madserverdocabs/tempReports
>  
>  puts "Making link to experiments directory in $madserverdocabs"
> -catch { exec ln -s [file join $madroot experiments] \
> -           [file join $madserverdocabs experiments]}
> +catch { exec ln -s [file join $madroot experiments] $madserverdocabs }
> 
> ==============================
> These changes made it possible for me to compile it with a f90 compiler
> for the Solaris build. The fortran libraries are now specified in the
> configuration file instead.
> The GNU build, however, succeed without changes.
> 
> diff -u -r1.7 configureMake
> --- configureMake	4 Feb 2003 16:42:13 -0000	1.7
> +++ configureMake	1 Jul 2003 07:16:17 -0000
> @@ -19,6 +19,7 @@
>  set found "false"
>  # set default value for FORTLIBSOLARIS
>  set FORTLIBsolaris "FORTLIB = /usr/local/lib"
> +set FORTLIBSsolaris "FORTLIBS = -lF77 -lM77 -lsunmath"
>  while {[gets $fc line] >= 0} {
>      if {[string range $line 0 8] == "MADROOT ="} {
>          set madrootval [string range $line 9 end]
> @@ -52,6 +53,9 @@
>          set i1 [string first "/" $line]       
>          set FORTLIBsolaris "FORTLIB = [string range $line $i1 end]"
>      }
> +    if {[string range $line 0 16] == "FORTLIBSSOLARIS ="} {
> +        set FORTLIBSsolaris "FORTLIBS = [string range $line 17 end]"
> +    }
>      if {[string range $line 0 10] == "TCLLIBDIR ="} {
>          set i1 [string first "/" $line]       
>          set TCLLIBDIR "TCLLIBDIR = [string range $line $i1 end]"
> @@ -111,6 +115,7 @@
>              [string match "CC =*" $line] == 1 ||
>              [string match "FC =*" $line] == 1 ||
>              [string match "FORTLIB =*" $line] == 1 ||
> +            [string match "FORTLIBS =*" $line] == 1 ||
>              [string match "TCLLIBDIR =*" $line] == 1 ||
>              [string match "TKLIBDIR =*" $line] == 1 ||
>              [string match "TCLLIB =*" $line] == 1 ||
> @@ -173,6 +178,15 @@
>               } elseif {[string match "FORTLIB =*" $line] == 1} {
>                  if {[string match "*solaris*" $f] == 1} {
>                      puts $fpn $FORTLIBsolaris
> +                } elseif {[string match "*gnu*" $f] == 1} {
> +                    puts $fpn $FCgnu
> +                } else {
> +                    puts "Error processing $f - neither solaris .nor. Gnu"
> +                }
> +                
> +             } elseif {[string match "FORTLIBS =*" $line] == 1} {
> +                if {[string match "*solaris*" $f] == 1} {
> +                    puts $fpn $FORTLIBSsolaris
>                  } elseif {[string match "*gnu*" $f] == 1} {
>                      puts $fpn $FCgnu
>                  } else {
> diff -u -r1.9 madrigal.cfg.template
> --- madrigal.cfg.template	4 Feb 2003 16:51:34 -0000	1.9
> +++ madrigal.cfg.template	1 Jul 2003 07:16:17 -0000
> @@ -8,6 +8,7 @@
>  FCSOLARIS = /opt/local/SUNWspro/bin/f77
>  # The location of the Fortan libraries F77, M77, and sunmath
>  FORTLIBSOLARIS = /opt/local/SUNWspro/lib
> +FORTLIBSSOLARIS = -lF77 -lM77 -lsunmath
>  
>  # These must be changed if madrigal will be installed using
>  # Gnu compilers.
> diff -u -r1.18 Makefile.solaris
> --- source/madc/madrec/Makefile.solaris	4 Apr 2003 17:39:34 -0000	1.18
> +++ source/madc/madrec/Makefile.solaris	1 Jul 2003 07:16:26 -0000
>  BINDIR = $(MADROOT)/bin/solaris
>  
>  # Solaris Fortran library directory (where libF77, etc is)
> -FORTLIB = /usr/lib
> +FORTLIB = /opt/SUNWspro/lib
> +
> +FORTLIBS =  -lfsu -lsunmath
>  
>  # ----------------------------------------------------------------------
>  #       End of site-dependent definitions
> @@ -47,7 +49,7 @@
>  # ----------------------------------------------------------------------
>  
>  LDLIBS = -L$(LIBDIR) -lmadrec -lnsl -lgeo  \
> -         -L$(FORTLIB) -lF77 -lM77 -lsunmath -lm
> +         -L$(FORTLIB) $(FORTLIBS) -lm
>  
>  # ----------------------------------------------------------------------
>  #       C compiler options 
> diff -u -r1.3 Makefile.solaris
> --- source/madc/madtcl/Makefile.solaris	4 Feb 2003 16:48:37 -0000	1.3
> +++ source/madc/madtcl/Makefile.solaris	1 Jul 2003 07:16:27 -0000
> @@ -24,28 +24,29 @@
>  BINDIR = $(MADROOT)/bin/solaris
>  
>  # Solaris Fortran library directory (where libF77, etc is)
> -FORTLIB = /usr/lib
> +FORTLIB = /opt/SUNWspro/lib
> +FORTLIBS =  -lfsu -lsunmath
>  
>  # Tcl library directory
> -TCLLIBDIR = /opt/tcl/src/tcl8.0/unix/lib
> +TCLLIBDIR = /usr/local/lib
>  
>  # Tk library directory
> -TKLIBDIR = /opt/tcl/src/tk8.0/unix/lib/
> +TKLIBDIR = /usr/local/lib
>  
>  # Tcl library
> -TCLLIB = tcl8.0
> +TCLLIB = tcl8.4
>  
>  # Tk library
> -TKLIB =  tk8.0
> +TKLIB =  tk8.4
>  
>  # Tcl include directory
> -TCLINCLUDE = /opt/tcl/src/tcl8.0/generic
> +TCLINCLUDE = /usr/local/include
>  
>  # Tk include directory
> -TKINCLUDE = /opt/tcl/src/tk8.0/generic
> +TKINCLUDE = /usr/local/include
>  
>  # Tcl interpreter
> -TCLSH = /opt/tcl/src/tcl8.0/unix/bin/tclsh8.0
> +TCLSH = /usr/local/bin/tclsh
>  
>  # ----------------------------------------------------------------------
>  #       Print Command
> @@ -66,12 +67,12 @@
>  LDLIBSTCL = -L$(LIBDIR) -lmadrec \
>              -L$(TCLLIBDIR) -l$(TCLLIB) \
>              -ldl -lsocket -lm -lnsl -lgeo \
> -            -L$(FORTLIB) -lF77 -lM77 -lsunmath
> +            -L$(FORTLIB) $(FORTLIBS)
>  
>  LDLIBSTK = -L$(LIBDIR) -lmadrec \
>             -L$(TKLIBDIR) -l$(TKLIB) -L$(TCLLIBDIR) -l$(TCLLIB) \
>             -L/usr/openwin/lib -lX11 -ldl -lsocket -lm -lnsl -lgeo \
> -           -L$(FORTLIB) -lF77 -lM77 -lsunmath
> +           -L$(FORTLIB) $(FORTLIBS)
>  
>  # ----------------------------------------------------------------------
>  #       C compiler options 
> diff -u -r1.3 Makefile.solaris
> --- source/madmatlab/Makefile.solaris	27 Jun 2003 14:56:28 -0000	1.3
> +++ source/madmatlab/Makefile.solaris	1 Jul 2003 07:16:28 -0000
> @@ -23,7 +23,8 @@
>  BINDIR = $(MADROOT)/bin/solaris
>  
>  # Solaris Fortran library directory (where libF77, etc is)
> -FORTLIB = /opt/local/SUNWspro/lib
> +FORTLIB = /opt/SUNWspro/lib
> +FORTLIBS =  -lfsu -lsunmath
>  
>  # ----------------------------------------------------------------------
>  #       End of site-dependent definitions
> @@ -46,7 +47,7 @@
>  # ----------------------------------------------------------------------
>  
>  LDLIBS = -L$(LIBDIR) -lmadrec -lnsl -lgeo  \
> -         -L$(FORTLIB) -lF77 -lM77 -lsunmath -lm
> +         -L$(FORTLIB) $(FORTLIBS) -lm
>  
>  
>  # ----------------------------------------------------------------------
> diff -u -r1.11 setup.py
> --- source/madpy/setup.py	24 Feb 2003 21:04:46 -0000	1.11
> +++ source/madpy/setup.py	1 Jul 2003 07:16:28 -0000
> @@ -49,7 +49,7 @@
>      metadataOrgFile = open('madrigal/metadata_original.py', 'r')
>  
>      # read file into string
> -    metadataStr = StringIO.StringIO(metadataOrgFile.read()).getvalue()
> +    metadataStr = metadataOrgFile.read()
>  
>      # substitute all values - order from longest to shortest for MADSERVER
>      metadataStr = string.replace(metadataStr, 'MADSERVERROOT', parser.get("madrigal", 'MADSERVERROOT'))
> @@ -73,6 +73,10 @@
>          fortLibStr = parser.get("madrigal", 'FORTLIBSOLARIS')
>      else:
>          fortLibStr = '/usr/lib'
> +    if parser.has_option("madrigal", 'FORTLIBSSOLARIS'):
> +        fortLibsStr = parser.get("madrigal", 'FORTLIBSSOLARIS')
> +    else:
> +        fortLibsStr = '-lF77 -lM77 -lsunmath'
>  
>      # substitute MAXGLOBALQUERIES only if it exists, otherwise set to blank
>      if parser.has_option("madrigal", 'MAXGLOBALQUERIES'):
> @@ -89,10 +93,10 @@
>      # close madrigal.cfg
>      madConfFile.close()
>  
> -    return (fortLibStr)
> +    return (fortLibStr, fortLibsStr)
>  
>  # call the function above
> -fortLibStr = createMetadataPyFile()
> +fortLibStr, fortLibsStr = createMetadataPyFile()
>  
>  # determine whether setup is running on linux.  If so, setup needs to be called
>  # with extra_link_args = ['-Xlinker -R' + os.environ['MADROOT'] +"/lib"]
> @@ -101,6 +105,8 @@
>  
>  if string.find(sys.platform, 'linux') == -1:
>  
> +    fortLibs = [ x.replace('-l','') for x in fortLibsStr.split() ]
> +
>      # solaris (or non-linux)
>      setup(name="madpy",
>              version="1.0",
> @@ -114,7 +120,7 @@
>                                    include_dirs=[os.environ['MADROOT'] + "/source/madc/include"],
>                                    library_dirs =[os.environ['MADROOT'] +"/lib", fortLibStr],
>                                    runtime_library_dirs =[os.environ['MADROOT'] +"/lib", fortLibStr],
> -                                  libraries=["madrec", "geo","F77","M77","sunmath"]
> +                                  libraries=["madrec", "geo"]+fortLibs
>                                    )
>                          ]
> 
> ==============================
> make clean now removes the programs too.
> 
> diff -u -r1.18 Makefile.gnu
> --- source/madc/madrec/Makefile.gnu	4 Apr 2003 17:39:34 -0000	1.18
> +++ source/madc/madrec/Makefile.gnu	1 Jul 2003 07:16:26 -0000
> @@ -76,13 +76,14 @@
>  #       Libraries and Programs
>  # ----------------------------------------------------------------------
>   
> -all: libmadrec.a libmadrec.so.1 testMadrec testMadrecs \
> +BIN = testMadrec testMadrecs \
>       testMadrecSequentialFileIO testMadrecRandomFileIO \
>       testCedarIO testCedarIOBoundaries testCedarMemIO \
>       testMadrecMemIO testMadrecRand translateCedarFile testCreateRecord \
>       compareFiles testParmArray testGeometry testMetadata fileDump repairHC \
>       splitCbfFile testMaddata simpleMaddata simpleNonfileMaddata \
> -     testMaddataErrors verify
> +     testMaddataErrors
> +all: libmadrec.a libmadrec.so.1 $(BIN) verify
>  
>  libmadrec.a: $(OBJECTS)
>  	ar rv $@ $(OBJECTS)
> 
> ==============================
> A typo.
> 
> diff -u -r1.1 README
> --- source/madc/madrec/README	22 Mar 2002 16:39:39 -0000	1.1
> +++ source/madc/madrec/README	1 Jul 2003 07:16:26 -0000
> @@ -13,5 +13,5 @@
>  4. runMadrecDiagnostics - This executes a series tests on all supported
>     Cedar file types.
>  
> -5. Make -f Makefile purify (If on a system that supports purify). Then
> +5. Make -f Makefile.purify (If on a system that supports purify). Then
>     execute runMadrecDiagnostics.
> 
> ==============================
> Prevents compiler warnings about undeclared strtok_r
> 
> diff -u -r1.16 maddata.c
> --- source/madc/madrec/maddata.c	15 Apr 2003 13:20:53 -0000	1.16
> +++ source/madc/madrec/maddata.c	1 Jul 2003 07:16:27 -0000
> @@ -4,6 +4,7 @@
>    Written 11/2002 by B. Rideout
>  */
>  
> +#define _REENTRANT
>  #include <maddata.h>
>  #include <madDeriveEngine.h>
>  
> diff -u -r1.6 maddataF77.c
> --- source/madc/madrec/maddataF77.c	29 Apr 2003 18:19:41 -0000	1.6
> +++ source/madc/madrec/maddataF77.c	1 Jul 2003 07:16:27 -0000
> @@ -208,6 +208,7 @@
>  
>  #include <stdlib.h>
>  #include <stdio.h>
> +#define _REENTRANT
>  #include <string.h>
>  #include <maddata.h>
>  
> ==============================
> Prevents segmentation fault when open fails.
> 
> diff -u -r1.10 testMadrec.c
> --- source/madc/madrec/testMadrec.c	26 Dec 2002 16:15:31 -0000	1.10
> +++ source/madc/madrec/testMadrec.c	1 Jul 2003 07:16:27 -0000
> @@ -58,6 +58,8 @@
>      /* Connect the madrec object to a madrigal file */
>      madrecOpen(madrecp, 30, madfile);
>      printf("open: %s\n", madrecGetError(madrecp));
> +	if (strcmp(madrecGetError(madrecp), "No errors"))
> +		return -1;
>  
>      /* specify a record by date and time */
>      key = getKey(1998, 1, 20, 15, 0, 0);
> 
> ==============================
> Move all javascript to an own "file". This makes the HTML code valid,
> as embedded JavaScript should not contain closing tags. An alternative
> solution would be writeing like document.write("<\/HTML>").
> This solution saves some bandwidth for non-javascript browsers too.
> 
> Index: source/madpy/scripts/cgi/madSearch
> ===================================================================
> RCS file: /opt/local/MillstoneCVS/OpenMadrigal/madroot/source/madpy/scripts/cgi/madSearch,v
> retrieving revision 1.10
> diff -u -r1.10 madSearch
> --- source/madpy/scripts/cgi/madSearch	25 Jun 2003 20:14:46 -0000	1.10
> +++ source/madpy/scripts/cgi/madSearch	1 Jul 2003 07:16:28 -0000
> @@ -167,6 +167,11 @@
>              # process requested login or password change
>              self.success = ''
>              
> +            # output javascript if told so
> +            if os.environ.get('QUERY_STRING') == 'js':
> +                self.outputJavaScript()
> +                sys.exit()
> +
>              # output html
>  
>              #print header
> @@ -343,13 +348,25 @@
>          print '<head>'
>          print '\t<title>' + title + '</title>'
>          print '\t<style type="text/css">.lb {background: #eeeeff}</style>'
> -        self.printJavaScript()
> +        if 0:   # this is not standard compilant as the javascript block
> +                # contains embedded </
> +            print '<script language="JavaScript" type="text/javascript"><!--'
> +            self.printJavaScript()
> +            print '// -->\n</script>'
> +        else:
> +            print '<script language="JavaScript" type="text/javascript"',
> +            print 'src="'+self.__scriptName+'?js"></script>'
>          print '</head>'
>  
> +    def outputJavaScript(self):
> +
> +        print "Content-Type: application/x-javascript"
> +        print                               # blank line
> +        self.scriptHeaders = 1
> +        self.printJavaScript()
>  
>      def printJavaScript(self):
>          
> -        print '<script language = "JavaScript">'
>          # data verification functions
>          self.printPopup()
>          self.printTrim()
> @@ -372,7 +389,6 @@
>          self.printGetDesc()
>          self.printMLookup()
>          self.printCParamDiction()
> -        print '</script>'
>  
>  
>      def printPopup(self):
> 
> The removed line here closed two tags that was never opened.
> 
> @@ -1220,7 +1236,6 @@
>          self.printFreeForm3()
>  	self.printFreeForm4()
>  	self.printFreeForm5()
> -        print '\t\t</table></td>'
>  
>  
>      def printFreeForm1(self):
> 
> ==============================
> More incorrect HTML: a <td> apperared without surrounding <table></table>
> 
> diff -u -r1.7 getMadfile.cgi
> --- source/madtcl/cgi/getMadfile.cgi	24 Oct 2002 15:41:36 -0000	1.7
> +++ source/madtcl/cgi/getMadfile.cgi	1 Jul 2003 07:16:28 -0000
> @@ -54,7 +54,9 @@
>  		cgi_p "<INPUT TYPE=\"hidden\" NAME=\"fileName\" VALUE=\"$fileName\" SIZE=15>"    
>  
>  		cgi_p "<H3>Translate [file tail $fileName] to the following CEDAR file type:</H3>"
> -                cgi_table_data valign=top {
> +                cgi_center {
> +                cgi_table {
> +			    cgi_table_data valign=top {
>                      cgi_radio_button "fileType=0" checked
>                      cgi_put "Madrigal"
>                      cgi_br
> @@ -71,7 +73,7 @@
>                      cgi_put "NCAR ASCII"
>                      cgi_br
>                  }
> -                cgi_center {
> +                }
>                      cgi_submit_button "=Download File"
>                  }
>  		cgi_p "</FORM>"
> 
> ==============================
> Additionally, I suggest removing bin/ and lib/ directories from CVS as
> they only contains empty README files.
> 
> Tell me what you think about this! I will probably spam more patches on
> this list as I proceed with adding some experiment data.
> --
> Christian Häggström  | student computer science
>                      | maintainer of www.eiscat.com
> _______________________________________________
> OpenMadrigal-developers mailing list
> OpenMadrigal-developers at openmadrigal.org
> http://www.openmadrigal.org/mailman/listinfo/openmadrigal-developers
> 





More information about the OpenMadrigal-developers mailing list