Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

f_interface.C

Go to the documentation of this file.
00001 
00002 // Interface to let FORTRAN routines use (C++) Starlab scattering routines.
00003 
00004 #include "scatter3.h"
00005 #include "fc_interface.h"
00006 
00007 // The FORTRAN common blocks are now precisely C++ structures,
00008 // so no additional conversion should be required, apart from
00009 // Sun's idiotic trailing underscores on global names...
00010 
00011 #ifdef FORTRAN_TRAILING_UNDERSCORE
00012 #  define INIT  init_
00013 #  define INTER inter_
00014 #  define FINAL final_
00015 #else
00016 #  define INIT  init
00017 #  define INTER inter
00018 #  define FINAL final
00019 #endif
00020 
00021 extern initial_state3 INIT;
00022 extern intermediate_state3 INTER;
00023 extern final_state3 FINAL;
00024 
00025 // WARNING: This is likely to be machine-dependent, and hence unreliable,
00026 // because we cannot be certain how any given compiler will arrange data
00027 // in memory.
00028 
00029 // We are ASSUMING here that the FORTRAN common blocks defined in
00030 // f_scatter3.h are aligned by f77 in the same way as the C/C++ init,
00031 // inter, and final structures are aligned by (g)cc.  If problems arise,
00032 // they usually do so in the "system" portions of the structures.
00033 
00034 extern "C" {
00035 
00036     /* --------- Initialize, return CPU time: as for C --------- */
00037 
00038     void f_cpu_init()
00039         {cpu_init();}
00040 
00041     real f_cpu_time()
00042         {return cpu_time();}
00043 
00044 
00045     /* --------- Initialize, return, print random numbers: --------- */
00046 
00047     int f_srandinter(int* seed, int* n_rand)
00048         {return srandinter(*seed, *n_rand);}
00049 
00050     real f_randinter(real* a, real* b)
00051         {return randinter(*a, *b);}
00052 
00053     void f_print_initial_random_parameters()
00054         {c_print_initial_random_parameters();}
00055 
00056 
00057     /* --------- Initialize standard initial state for scattering: --------- */
00058 
00059     void f_make_standard_init()
00060         {make_standard_init(INIT);}
00061 
00062     void f_initialize_angles(int* planar_flag, int* psi_flag, real* psi)
00063         {c_initialize_angles(&INIT, *planar_flag, (bool) *psi_flag, *psi);}
00064 
00065 
00066     /* --------- Print information on scattering: --------- */
00067 
00068     void f_print_scatter3_info(int* Q_flag, int* q_flag, int* b_flag,
00069                                real* cpu)
00070         {c_print_scatter3_info(&INIT, &INTER, &FINAL,
00071                                (bool) *Q_flag, (bool) *q_flag, (bool) *b_flag,
00072                                *cpu);}
00073 
00074     void f_print_intermediate_descriptor(int* descriptor)
00075         {cout << "    descriptor =   "
00076               << state_string((intermediate_descriptor3) *descriptor) << endl;}
00077 
00078     void f_print_final_descriptor(int* descriptor)
00079         {cout << "    descriptor       =   "
00080               << state_string((final_descriptor3) *descriptor) << endl;}
00081 
00082 
00083     /* --------- Perform a scattering experiment: --------- */
00084 
00085     void f_scatter3(real* cpu_time_check,
00086                     real* dt_out,
00087                     real* dt_snap,
00088                     real* snap_cube_size)
00089         {scatter3(INIT, INTER, FINAL, *cpu_time_check,
00090                   *dt_out, *dt_snap, *snap_cube_size);}
00091 
00092     // Note: For unknown reasons, the system reports uncleared IEEE
00093     // errors (Inexact;  Division by Zero; Invalid Operand) when
00094     // this routine is used on Suns.  The results appear to be fine.
00095 
00096     // This is almost certainly related to data alignment problems
00097     // in the "system" part of the structures and common blocks,
00098     // but I'm not sure why that should be the case...
00099 }

Generated at Sun Feb 24 09:57:00 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001