Was this helpful?
Coding FORTRAN Procedures
Use the format described for your operating system.
Coding FORTRAN Procedures (UNIX)
Use the format below when coding a FORTRAN procedure:
subroutine procname
    processing statements 
end
In FORTRAN, the procedure is declared as a subroutine or function. It cannot be a program.
Integers are passed as four bytes by reference, floats are passed as double-format floats by reference, and strings are passed in accordance with the string format used by your FORTRAN compiler. Use the character *(size) format for all character types, where size corresponds to the actual length of the table field or is large enough to hold any expected string. Consider this call to a procedure q:
callproc q (1 + 2, 2.3, 'This is a string');
The following declarations are required:
subroutine         q(x,y,z)
integer            x
real*8             y
parameter          (MAXSTR = 512)
character          *(MAXSTR)z
FORTRAN subroutines cannot return values to 4GL. To return a status to 4GL, the called procedure must be a FORTRAN function rather than a subroutine.
A FORTRAN function returns integer, real*8, or character *(size) values. The maximum allowable size for a string is 512 bytes. FORTRAN does not return the actual size of the string to 4GL. If the receiving string in 4GL is a variable-length character type, trailing blanks are truncated when the string returns. The three procedures are shown below.
To return an integer:
integer function reti
reti = 10
end
To return a floating-point value:
real*8 function retf
retf = 10.5
end
To return a character string:
character *(20) function rets
rets = 'Returned from rets'
end
Coding FORTRAN Procedures (VMS)
Use the format below when coding a FORTRAN procedure:
subroutine procname
    processing statements 
end
In FORTRAN, the procedure is declared as a subroutine or function. It cannot be a main program.
Integers are passed as four bytes by reference, floats are passed as double-format floats by reference, and strings are passed by descriptor. Use the character *(*) format for varchar and vchar types. The fixed-length format character (size) can be used for 4GL char and c data types.
Consider this call to a procedure q:
callproc q (1 + 2, 2.3, 'This is a string');
The following declarations are required:
subroutine        q(x,y,z)
integer           x
real*8            y
character *(*)    z
FORTRAN subroutines cannot return values back to 4GL. To return a status to 4GL, the called procedure must be a FORTRAN function rather than a subroutine.
A FORTRAN function must return integer, real*8, or character*(*) values. The maximum allowable size for a string is 512 bytes. FORTRAN does not return the actual size of the string to 4GL. If the receiving string in 4GL is a variable-length character type, trailing blanks are truncated when the string returns. The three procedures are shown below.
To return an integer:
integer function reti
reti = 10
end
To return a floating-point value:
real*8 function retf
retf = 10.5
end
To return a character string:
character *(*) function rets
rets = 'Returned from rets'
end
Last modified date: 01/30/2023