Introduction
This details what is done to get the ORIC accelerator code to work at UC Davis under modern Windows systems. The main issue is that the code was initially written in Fortran IV, then later updated with Fortran 77 in a very sloppy way. In particular, they mixed Hollerith strings and character strings. This was allowed under Microsoft Fortran 5.1, but the newest operating system that that still runs on is Windows XP, so that is how the code was initially compiled. The details of that can be found here.
Another issue is that some of the utility programs were written under Visual Basic 5. They were run under Visual Studio 6 under the Windows XP system described above.
There are two main issues with running the code under new versions of Windows:
- Most modern Fortran compilers are much less forgiving about the Hollerith and character string mixing, leading to many fatal errors. Using the Intel Fortran compiler ameliorates this a great deal, requiring only a few changes to make the code compile. This also allows the code to be compiled on a Mac.
- Visual Studio completely changed the interface for Visual Basic after Visual Studio 6, moving to the .NET format. I experimented with updating the projects to the new format, but there were HUGE problems with the plotting programs and some other stuff, so in the end, I found at way to get VB6 to install on Windows 11.
All the code is maintained at the repository https://github.com/prebys/ORIC
Latest Updates
- 20230713: All FORTRAN and VB code compiled under Win11 and copied to “1.Orbit Calculations”. Tried to write a batch file to automate this process but it doesn’t work for some reason. Got rid of all .NET projects, because they confuse things. Pushed changes to github and release as v1.2
Modifying FORTRAN Code
You’ll need to download the standalone version of the Intel FORTRAN compiler (OneAPI) here.
You then open the OneAPI window, go to the source directory and compile with
ifort /c filename.for
You can then compile with, eg
ifort file1.for file2.for file3.obj
This compiler will forgive most of the Hollerith/character mixed except for building longer character strings out of integers, so some updates are needed. Specific changes are (all of these are subdirectories in the ‘5.Source Codes’ directory):
- JBACCEL\
- jbaccel.for and acclib.for: changed a few INTEGERs to CHARACTER*4. All are flagged with “EjP”
- updated batch files for Intel compiler
- JBFLDMAN\
- jbfldman.for: changed on INTEGER*4 to CHARACTER*4. Flagged with “EjP”
- updated CFM.BAT for Intel compiler
- JBPFIELD\
- No changes needed to jbpfield.for
- updated batch files for Intel compiler
- SPIRALJ\
- Compiles with one “remark” about formatting, which I’m ignoring for now
- JBISOC\
- Created IA1 and IA4 EQUIVALENCES for CHARACTER*4 A1 and A4.
- Declared DAT as CHARACTER*4. All flagged with “EjP”
- There was an unresolved link error over an external variable MSGHDL. This seems to be for an old CNTL-C handling routine that has been commented out in ACCLIB.FOR has been commented out and doesn’t appear anywhere here anyway.
- A couple of formatting remarks about possible field overflow, which I suppress in the compilation batch file.
- Updated batch file for Intel compiler.
- JBEQORB\
- Declaring DAT as CHARACTER*4.
- Declared ARGSV as DOUBLE PRECISION (this appears to have just been an error)
- A couple of formatting remarks about possible field overflow, which I suppress in the compilation batch file.
- Updated batch file for Intel compiler.
As of July 12, 2023, all FORTRAN files compile and link on Windows 11 under the Intel compiler. It’s not verified if they work as expected. It should also compile under Win 10, but that hasn’t been tested.
Visual Basic Files
There are four Visual Basic programs in the ORIC code:
- \JBCSTART\CARSTART.vbp: sets up the initial cards for the simulation. Builds JBCSTART.EXE
- \JBDPLOT\JBDPLOT.vbp: plots the output
- \JTRACE\JTrace.vbp: ??
- \JTRACE\HarmonicA/HarmonicA.vbp: ??
I originally tried to update the VB projects to the new .NET format, as described at the end of this document. This worked well for the CARSTART program, but the plotting programs have LOTS of obsolete methods that would have taken forever to fix, so I managed to find a hack to install.
Download Visual Studio 6 from here. This will give you .ISO image, which you can unpack with 7-ZIP. You can right-click->mount the .ISO file to see the contents, but you’ll need to modify some things, so copy the entire contents to a new directory.
Then follow the instructions here. I have no idea what’s meant by Step 4, so I just skipped it. This will give a really old timey install screen that takes up the whole screen. You’ll need a product key, but believe it or not 111-1111111.
There’s a generic bug/feature running under Windows 11 that programs default to the Visual Basic installation directory rather than the directory the program is running in. This led me on a merry chase, but I fixed it by adding the following code at the top of the main() routine in every VB program:
' For some reason, when running on Win 11, you have to explicitly set the working directory to the ' Application directory. Since I'm building this code in a Virtual machine on the Mac, I also have to ' add a kludge to replace "\\Mac\Home" with "Z:". There's probably a more elegant way to do it. ' EjP 20130712 fixpath = Replace(App.Path, "\\Mac\Home", "Z:") ChDrive fixpath ChDir fixpath '--EjP
Updated files:
- /JBCSTART/CARSTART.vbp: This immediately compiled and ran after the patch described above; however, the ORIC system was limited to 19 MHz, so I changed the limit to 24 rather than 19 (actually higher than ours, too). This is done by changing a test in CARSTART.vb as well as the text on frmCARSTART.vb.
- /JBDPLOT/JBDPLOT.vbp: Applied directory fix. When I tried to compile this, I got unknown methods for the CommonDialog1 entries in the mnuPrint_Click() routine of frmDplot, so I commented them out. The program now runs, but this probably affects printing, which has not been tested.
- /JTRACE/JTrace.vbp: Applied directory fix. When I tried to run it, I got an index out of range error when it tried to access X(-1) in the routine PlotInfo. I added a test and it ran, but nothing is actually plotted. Not sure if this worked on the original. Need to check it out.
- JTRACE/HarmonicA/HarmonicA.vbp: This appears to be a simple program to do one calculation. It doesn’t read or write any files, so it didn’t need the directory fix. It compiled and ran immediately.
Updating Visual Basic Projects to .NET Format
The latest Visual Studio will not open the older (.vbp) files at all, so you need so use the conversion tools in Visual Studion 8, which you can download from here. This is a 90 evaluation version. Hopefully before then, we can upgrade all the versions, or we can figure out a way to go to Pro.
The only one I successfully updated was the CARSTART program. This calculates the RF frequencies and coil currents based on particle type, energy, and extraction radius. From the VS8, open project CARSTART.vbp, this will launch the conversion wizard. Accept all defaults. This will create a subdirectory CARSTART.NET and move all the updated source files there, after which all the original files will be ignored. The process will generate a LOT of warnings about “default properties”, but they can mostly be ignored.
You can debug the program with Project->Debug. It initially crashed due an ambiguous type cast. This was fixed by declaring “E” as a Decimal rather than an Object. This is flagged with “EjP”.
The ORIC cyclotron has a lower RF limit than ours, so I changed the limit to 24 rather than 19 (actually higher than ours, too). This is done by changing a test in CARSTART.vb as well as the text on frmCARSTART.vb.
Recent Comments