views:

39

answers:

2

Hey everybody, i am deploying my code from a cluster running on ubuntu onto a cluster with identical hardware, but with red hat and as it seems older gfortran compiler. The source is actually compiled by ifort, but since it is not installed on the red had cluster, i may have to switch to gfortran.

Now the problem is that the code does not compile. There is this thing with "allocatable" inside a type that i could fix in my portion of the code, but there are also other contributions by other people not as ready to adapt their code to the older standard.

My question :

  1. How do i deploy nonetheless onto the other system, hopefully without changing much?
  2. What other surprised wait for me when using the compile from the same version, just different subversion?
  3. How do i enforce that something like this does not happen again? The code should be deployable onto a variety of systems without resorting to violence.

Thanks for your advice and cheers

+1  A: 

I think you have 3 choices:

  1. Cross-compilation: ie compile on your development machine for execution on your deployment machine; I don't know if this is possible with your setup but it is worth investigating if you haven't already done so.
  2. Program to the set of Fortran features implemented in all your compilers -- which would mean re-writing the code to take out whatever features 4.2.3 implements that 4.1.2 doesn't.
  3. Upgrade the compiler on your deployment machine to match the one on your development machine.

Of these I think that (1) might be difficult; if it is then I'd go for (3). If that is not possible, then it has to be (2) -- I don't see any other options.

Now to answer your questions:

  1. Answered above.
  2. Not sure, but the release notes for Gfortran should tell you what Fortran language features 4.2.3 implements which 4.1.2 doesn't.
  3. Only program with the version of Fortran for which you can compile on your target platforms.
High Performance Mark
thanks for your effort.
tarrasch
+1  A: 

gfortran started with version 4.0. Versions 4.1 and 4.2 are old and missing many features and may have bugs. You may run into additional missing features that are used by your code. I suggest, if at all possible, getting the compiler upgraded to the current stable version, which is 4.5.

Supporting all versions of gfortran will lead to many restrictions on your code. It might be better to identify the earliest version that works and add that information to the documentation. For my code, that version is 4.3 since I make extensive use of the ISO C Binding.

The gfortran wiki, http://gcc.gnu.org/wiki/GFortran, has a changelog by version that might help you identify which version you need. The only sure way is to test.

If you want to enforce a version requirement, you can test from within Fortran. You could run a small test program as part of the make process and abort if the gfortran version is too early.

The following code fragment shows two ways of outputting the gfortran version number from a Fortran program. Name the program with filetype ".F90" so that gfortran will invoke the preprocessor.

#ifdef __GFORTRAN__ 
    write (*, '( "gfortran" )' )
    write (*, '( I0, ".", I0 )' )  __GNUC__, __GNUC_MINOR__

! Merged version number:
#define GCC_VERSION (__GNUC__ * 10000  + __GNUC_MINOR__ * 100  + __GNUC_PATCHLEVEL__)
    write (*, '( I0 )' )  GCC_VERSION

#endif
M. S. B.
thanks i think i will try to convince the guys to upgrade their version of gfortran
tarrasch