Real Science

Translating Fortran To A Human Readable Language

Advertisements

Answer to yesterday’s riddle. What is the magic number 1196575042?

CALL GBYTE(Z,I4,(K+0)*8,4*8)
CALL GBYTE(Z,I1,(K+7)*8,1*8)
IF(I4.EQ.1196575042.AND.(I1.EQ.1.OR.I1.EQ.2)) THEN
   IF (I1.EQ.1) CALL GBYTE(Z,KG,(K+4)*8,3*8)
   IF (I1.EQ.2) CALL GBYTE(Z,KG,(K+12)*8,4*8)

The C equivalent is :

if ( !strncmp(Z, "GRIB", 4) )
{
   if (Z[7] == 1) strncpy(KG, &Z[4], 3);
   else if (Z[7] == 2) strncpy(KG, &Z[12], 4);
}
Advertisements

Advertisements