THis is a quick how to file for compiling an MSIS shared object library on UNIX machines. This is what I did on Solaris. I am sure there will be other painful things with Linux, but in theory it is very similar. UPDATE: SEE BOTTOM FOR OSX INSTRUCIONS!!! Errors you will encounter. ***coredump*************************************************** you are probably calling tselec or some other subroutine directly. You cant do that on UNIX machines! You need to write a wrapper. Melissa Lin at SwRI provides a good example. subroutine callghp6(argc,argv) integer*4 argc, argv(*) c c SUBROUTINE GHP6(IYD,SEC,ALT,GLAT,GLONG,STL,F107A,F107,AP, c $ D,T,PRESS) c nargs = loc(argc) if (nargs.ne.12) then write(6,"('call ghp6: wrong number of args=',i3, + ' (should be 12 args)')") nargs stop endif call ghp6(%VAL(argv(1)),%VAL(argv(2)),%VAL(argv(3)), + %VAL(argv(4)),%VAL(argv(5)),%VAL(argv(6)), + %VAL(argv(7)),%VAL(argv(8)),%VAL(argv(9)), + %VAL(argv(10)),%VAL(argv(11)),%VAL(argv(12))) return end Melissa wrote 4 wrappers, which should cover anything you want do to. callghp6.f callgtd6.f callgws5.f calltselec.f ***position independence************************************ You MUST compile all your FORTRAN and C using -fPIC ***sin undefined********************************************* You must LINK using -lm (lib math) ***r_mod undefined****************************************** Rmod corresponds to the double precision mod AMOD which MSIS90 uses once. Why this is not in any fortran library, who can say. To get it, you have to download the f2clib.zip file at bell_labs. Or elsewhere on the net. Try http://www.netlib.no/netlib/f2c/ Then compile all the .c files with -fPIC ***xargc undefined****************************************** This is a killer, which is unlike anything you've had to deal with yet. But we have an answer. Invaluable for this work was : http://www-acs.ucsd.edu/offerings/userhelp/HTML/mixedlang,d.html You will need to edit getarg_.c and iargc_.c in the manner described in the above document. These .c files are part of the f2c lib. Briefly from that work: ------------------------------------------------------------------ Note from experience: The SunPro 3.0 f77 compiler does not save xargc and xargv for use in C programs. If you are migrating existing code that assumes the existence of: extern int xargc; /* number of arguments in UNIX command */ extern char **xargv;/* pointer to an array of pointers to arguments in UNIX command line */ (THIS IS MOST IMPORTANT!!!!!!!) You will need to comment these lines out and add: int xargc; /* number of arguments in UNIX command */ char **xargv;/* pointer to an array of pointers to arguments in UNIX command line */ void f77_init(int *argcp, char ***argvp, char ***envp) { xargc=*argcp; xargv=*argvp; } This uses a separate function to set up the global variables. The f77_init function is called as part of the initialization of a fortran program. It is documented in the Answerbook. This method worked for compiling spice2g6 on iEng3. Your mileage, of course, may vary. -zz1ns ---------------------------------------------------------------- ****************************************************************** Anyway, the instructions are. 1) compile msise90.f and all your wrappers with g77 -fPIC -c *.f (-c gives you .o files only, you don't have a main) 2) compile all the f2c .c code after editing getarg_ and iargc_ gcc -fPIC -c *.c 3) throw then all in the same dir and gcc -shared -fm -o msis.so *.o That's it. MSIS calls from IDL should then work with the following: dum=call_external('msis.so','calltselec_',switch,1L) or result=call_external('msis.so','callgtd6_',iiyd,uts,alt,gla,glo,$ slt,f107m,f107, ap, 48L, den, temp) ----------------------------------------------------------------------- That was a pain in the ass! OK Now for Mac OS X. First, get g77 with fink! fink install g77 The compile is exactly as before g77 -fPIC -c *.f The link statement is quite different g77 -bundle -flat_namespace -dynamic -lm -lc -undefined suppress -o msis.so *.o If you don't do -undefined suppress, it will crash out /usr/bin/ld: Undefined symbols: _gws5_ Nice. Isn't that part of MSIS? Anyway, g77 was a pretty crucial call, because gcc -lM77 or -lG77 or whatever simply does not work in this case. This may have worked on solaris, without all the f2c biz. Who knows.