| [ CnUnix ] in KIDS 글 쓴 이(By): freezer (IceHouse) 날 짜 (Date): 1996년04월07일(일) 23시45분22초 KST 제 목(Title): [A] F77에서 함수를 매개변수로 .... 쩝.. 앞에 r] 을 다신 분께는 죄송합니다만.. 제가 아는 범위에서는 방법이 있습니다. EXTERNAL 과 INTRINSIC 을 쓰면 되죠. 다음 메뉴얼 (FORTRAN/9000 Reference :HP9000/700 series 을 베낀것) 을 보면 방법을 아실 수 있을겁니다. HP 용 fortran manual 에서 베낀거지만 F77 에서 아마도 공통적으로 쓰이는 명령일겁니다. ------------------------------------------------------------------------------- EXTERNAL The EXTERNAL statement identifies a symbolic name as a subprogram name and permits the name to be used as an actual argument in subprogram calls. The EXTERNAL statement also identifies a formal argument as a subprogram name and permits its use as that. Syntax EXTERNAL proc1 [,proc2] ... "proc" is the name of a subprogram. Each name can appear only once in a given EXTERNAL statement, and in at most one EXTERNAL statement in a given program unit. Rules and Description The EXTERNAL statement provides a means of using the names of subroutine subprograms and function subprograms as actual arguments in CALL statements. The EXTERNAL statement is necessary to inform the compiler that these names are subprograms or function names, not variable names. Whenever a subprogram name is passed as an actual argument, it must be placed in an EXTERNAL statement in the calling program. Inside the called procedure, if the formal argument is a subprogram name that is never referenced, it should also appear in an EXTERNAL statement within the procedure so the comiler can allocate sufficient storage for the argument. If an intrinsic function name appears in an EXTERNAL statement, the compiler assumes that a user subprogram by that name exists. Thus, the intrinsic function by the same name cannot be used in the same program unit. For example: PROGRAM MY_COS EXTERNAL COS REAL COS, X, Y READ(5,*) Y X = COS(Y) ! THIS CALL IS TO USER-WRITTEN WRITE(6,*) X ! FUNCTION NAMED COS, NOT TO THE END ! INTRINSIC FUNCTION COS. A name cannot appear in both an EXTERNAL and INTRINSIC statement. In addition, a statement function name must not appear in an EXTERNAL statement. Example In the following code, the EXTERNAL statement declares B1 to be a subprogram name. The call to SUB passes the values of A and C, and passes the names of the subprogram (B1). In the subroutine SUB, the reference to Y causes B1 to be called: EXTERNAL B1 CALL SUB(A,B1,C) . . . END . . . SUBROUTINE SUB(X,Y,Z) EXTERNAL Y X=Y(Z) RETURN END ------------------------------------------------------------------------------- INTRINSIC The INTRINSIC statement identifies a name as representing an intrinsic function and permits the name to be used as an actual argument. Syntax INTRINSIC fun [, fun2] ... "fun" is the name of an intrinsic function. Each name can appear only once in a given INTRINSIC statement, and in at most one INTRINSIC statement within a program unit. Rules and Description The INTRINSIC statement provides a means of using intrinsics as actual arguments. The INTRINSIC statement is necessary to inform the compiler that these names are intrinsic names and not variable names. Whenever an intrinsic name is passed to as an actual argument, it must be placed in an INTRINSIC statement in the calling program. The following intrinsics must not! be used as actual argument: * The names of intrinsic functions for type conversion (INT, FLOAT, etc.) * Logical relationships * Intrinsics that choose the largest or smallest value (MAX0, AMAX1, etc.) * The intrinsics LOG, LOG10, ZEXT, and BTEST. ------------------------------------------------------------------------------ 휴우.. 다 베꼈다..(제가 할일 없는 백수로 보이시죠?) 쩝.. 그런데 이 질문을 한 게스트분 혹시 내 룸메이트 아닌가 몰라.... |