[ghemical-devel] about symtrz.f
Tommi Hassinen
Tommi.Hassinen at uku.fi
Wed Aug 6 06:41:42 EDT 2008
Hello,
I haven't looked yet at the configure-scripts-related parts of the patchfile ; this might take a few days before I can arrange it.
But about these fortran files. I'm not a great fortran expert myself, and in the past I have been very careful in changing anything there. I have also retained the old code (in comments) and tried to explain why the change is needed.
There is really something hazy in symtrz.f ; g77 and gfortran wont compile this line:
DATA TOLER,IFRA / 0.1, '????'/
because it involves assignment of a string value '????' into an integer-type variable. Also f2c gives a warning about it but still accepts it. I don't have any idea what the subroutine is about and actually *what* it is doing. However, I don't think this is just a typo because NAMES exists three times there:
NAMES=IFRA
IF(J1.EQ.1) NAMES=JX(1,1)
DO 2 I=1,NORBS
INDEX(I)=I
2 NAMO(I)=NAMES
also right after initializing NAMES=IFRA the next code line will modify the value: IF(J1.EQ.1) NAMES=JX(1,1)
Now if we change the code by assuming it's just a typo and change it NAME=IFRA the result is that the original value
NAMES will be left without any proper initialization.
OK then, how to initialize NAMES if we can't put there the string value? I looked at C code produced by f2c and tried to get an answer there:
static doublereal toler = .1;
static struct {
char e_1[4];
integer e_2;
} equiv_167 = { "????", 0 };
#define ifra (*(integer *)&equiv_167)
The f2c program just makes a structure { "????", 0 } that represents IFRA.
Here is the definition of names-variable:
static integer names, ifound;
This code makes the assignment:
names = ifra;
I haven't tried to look what actually happens at runtime, but from the source it looks to me like names will get the value 0.
Therefore I decided to change
NAMES=IFRA
to
NAMES=0
This is accepted by both g77 and gfortran (at least this version:)
$ gfortran --version
GNU Fortran 95 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
I also ran all test files under test/ directory with the old f2c code and the modified code compiled with the fortran compilers and found no relevant changes ; but I have no idea how many times (if any) the code in symtrz.f is actually executed...
Any ideas how to catch the initial value of NAMES at runtime? By modifying the C source code to print it out and exit()??? But is the value relevant at all? Perhaps it is (code generated by f2c will have the same values in variables etc but final access to arrays is shifted by -1).
What about those changes in esp.f file ; what is the reason for changes there?
Regards,
Tommi
More information about the ghemical-devel
mailing list