real*8 function presvesf(Ys,P_i,R,t, ier) bind(C,name="PRESVESF") C ---------------------------- C General comments C ---------------------------- C Note that Fortran code must not start before column 7 in *.for files. C The allowed length of a line is up to (including) col.72 (as in the very first line of this file); C comment lines may be longer! C Continuation lines of code are marked by a character (1,2,3,... or *) in col.6. C A *.f90 file does not have the above restrictions. C Also note that Fortran is case INsensitive ! C ---------------------------- C Regarding the parameters C ---------------------------- C The names of the parameters are arbitrary and can be different C from the names in the Stochastic Model. C What matters is the order in which the parameters appear in the parameter list. C The number of parameters in the parameter list of this function must match C the number of parameters in the corresponding DEFFUNC-statement in the iti-file C plus an additional parameter that is used as error flag. C All parameters except the last one are of type 'double precision' or 'real*8'. C ---------------------------- C Concerning the function name C ---------------------------- C You can freely choose any function name that is up to 8 characters long. C Note: the function name appears at the following positions: C - twice in the very first line of the file: C 1) as the name of the Fortran function 'presvesf' (case insensitive) C 2) inside of the bind-statment as the name to use when linking this function to Comrel C e.g.: "PRESVESF" -> this name must always be specified in UPPERCASE and C -> the name must be enclosed in "" C If you forget to write this name in UPPERCASE letters, you will get error 90 'User defined DLL is missing'; C This name is case sensitive, because it is used to link this function to a programm written in C. C 3) in the DEC-attribute, e.g.: !DEC$ ATTRIBUTES DLLEXPORT::presvesf (case insensitive) C 4) in the return statement of this function that returns the result of the function call (case insensitive) C e.g.: presves=... C 5) last but not least the name also appears in the corresponding 'DEFFUNC' statement in the iti-file ! C ---------------------------- C The error flag 'ier' C ---------------------------- C If the function call was successfull, you should set the value of 'ier' to 0. C If evaluation of the function failed, return a value larger than zero. C The following compiler directive is mandatory for the interface and C is NO comment despite that ! marks a comment as does C in col.1. !DEC$ ATTRIBUTES DLLEXPORT::presvesf implicit none C We declare all variables explicitly: double precision, intent(in), value :: YS, P_i, R, t C double precision is the same as real*8 C value tells that the real arguments are passed by value integer, intent(out) :: ier C whereas the integer output argument ier is passed by reference presvesf=Ys-(P_i*R/(t/1000.d0))*sqrt(0.75d0) C make real constants real*8 or double precision like 1000.d0 ier=0 end function