0
votes

I have a Windows DLL came from a FORTRAN code. The DLL is working but I need to change it and port to Linux.

Now I'm trying to wrap it into a Java code using this and trying to compile with gfortran too.

I'm facing an issue like Error: Unclassifiable statement at (1) but searching around I read this error is too generic and related to many things, none of them related to my code (or I think so).

Here is the problematic code:

...
character*2 di,mi
character*4 ai
...
integer*2 dia_ini, mes_ini, ano_ini
...

decode (2, '(i2)', mi ) mes_ini
decode (2, '(i2)', di ) dia_ini
decode (4, '(i4)', ai ) ano_ini

...

All decode lines are giving error at beginning of line (the "1" is pointing below the d of "decode")

One thing I can't understand is `di,mi' and 'ai' are in parameter list too:

Subroutine PREVISAO (di,mi,ai)

Is this allowed on Fortran? Aren't the initial values on parameters lost?

The original files have a .f90 extension and have only subroutine blocks.

1
Sounds still like a problem of fixed form versus free form code. Does your file still have the .f90 extension when not try it, otherwise it sounds a bit like a missing compilation option in your tool-chain. Possible workaround might be to insert 6 spaces at the beginning of each line. - albert
@francescalus are you sure? So it must be very similar. All until this line (635) goes fine. - Magno C
docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn87/index.html - Magno C
From that page "ENCODE and DECODE are not in the FORTRAN 77 Standard". As you've tagged gfortran the link given in answer to the other question cover gfortran's support for this extension. You should use a compiler such as Oracle's or rewrite the code using supported code (internal reads, perhaps). - francescalus

1 Answers

3
votes

As mentioned in the comments, DECODE (and ENCODE) is not part of the Fortran standard, and GFortran does not support this particular extension. In the GFortran manual you can find examples how to convert ENCODE and DECODE into standard Fortran constructs using internal READ/WRITE statements: https://gcc.gnu.org/onlinedocs/gfortran/ENCODE-and-DECODE-statements.html