- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wish to make it clear that I am not recommending the following, but I think it should compile and run, see error messages attached
program TEST_PRESENT implicit none call TEST_PRESENT_check stop contains subroutine TEST_PRESENT_check(present) logical, optional, intent(out) :: present if(present(present)) present = .true. end subroutine TEST_PRESENT_check end program TEST_PRESENT ! Output: !1>Compiling with Intel(R) Visual Fortran Compiler 19.1.1.216 [IA-32]... !1>test_present.f90 !1>...\test_present.f90(8): error #6410: This name has not been declared as an array or a function. [PRESENT] !1>...\test_present.f90(8): error #6341: A logical data type is required in this context. [PRESENT] !1>compilation aborted for ...\test_present.f90 (code 1) !1> !1>Compiling with Intel(R) Visual Fortran Compiler 19.1.1.216 [Intel(R) 64]... !1>test_present.f90 !1>...\test_present.f90(8): error #6410: This name has not been declared as an array or a function. [PRESENT] !1>...\test_present.f90(8): error #6341: A logical data type is required in this context. [PRESENT] !1>compilation aborted for ...\test_present.f90 (code 1) !1>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Gilles has it exactly right. Fortran has no reserved words and you can redeclare all of the intrinsics. By declaring PRESENT as a dummy argument, that hides the intrinsic.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it's normal. you declare a "present" variable so the external "present" function is not seen anymore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Gilles has it exactly right. Fortran has no reserved words and you can redeclare all of the intrinsics. By declaring PRESENT as a dummy argument, that hides the intrinsic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Both
I had not realised that was a "feature", and makes me wonder about other examples, but where a syntax error does not result.
Thanks for your responses.
N
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might enjoy this, then. Nowadays the compiler will grumble, but it serves to illustrate how confusing things can get if you try. This was written by Stan Rabinowitz at DEC in the 1980s, and a lot of it is non-standard, but it's amusing nonetheless.
program segment C C C IMPLICIT INTEGER *2(O), LOGICAL(T-U) COMMON// UNCOMMON// COMMON INTEGER FLOATING_POINT REAL IMAGINARY COMPLEX SIMPLE INTRINSIC EXIT EXTERN ALL,SOME,NONE SAVE NOW DOUBLE PRECISION A = 3 ASSIGN 3 TOO THREE 3 FORMAT((())) IF (THEN) THEN END IF E 1 N 2 D DOUBLE COMPLEX FUNCTION FN(ARG1,DOUBLE FN,DOUBLE) COMPLEX DOUBLE FN(ARG1) DIMENSION DOUBLE(-8:-7,-6:*) VIRTUAL STORAGE(8/7) COMPLEX*1 6MEN_IN_A_BOAT, THEN THERE WERE 5 UNLOCK THE DOOR IF (1) 2,3,4 4 IF (4HCLUB) 37, 6, 5 5 DO 37 I=1.5 CALL F(04*05,*06) 37 CONTINUE 6 STOP '4X' 2 A='4X' 3 A='4'X DELETE (3) INSANITY=%LOC(1.2D5) RETURN END SUB ROUTINE FORMAT(*) REAL ROUTINE ______ REAL(ROUTINE)=1E1 DO WHILE (1 .NEQV. 2) READ(ERR=7,UNIT=7) 123 READ(3'X) 456 READ *,X *89 READ(UNIT=*,X) 777 READ UNIT=9 ENDDO 007 CALL FRAME(A ONE, &2, AND A 3) 2 Q=3Q1 ENTRYST(Z 9) RETURN 71 END REAL*4 ROUTINE TRICKY END IMPLICIT INTEGER*4(X), INTEGER*2(O-Q) DIMENSIONLESS VAR(1**1) BYTE BYTE 0 DO 1, I=2,3 100 FORMAT(I7.4,Z8.2,G5.2e4,2p/TL7Q:$!L1,B12.9,J6 X SPSSBZQX'garbage') 101 FORMAT(<(1,2)>I) 102 FORMAT(L<I3(I4/'ABC')>) 10 3 FORMAT(I) 1 CONTINUE X=3 DATA X/4/ GOTO 42 43 DO 44 I=1,9,-3 42 IF (I) 43,44,45 44 END IF = 9 45 I will bet you $25 that 4=2+3. ASSIGN 100 TO QTEST GO TOPLESS! E N D CHARACTER*8 FUNCTION CHOMP(A,B,C,D,E,STAR) DIMENSION B(C:D,0:0,0:0,0:0,0:0,0:00,0:0) COMMON /PQRST/ UVWX,YZ // L REAL REAL(3.14159D4) ! really? CHARACTER*(*) STAR(*) BYTE E(65537+L*A/9-1) STAR(1)(2:3)=CHOMP//'FOOD' REAL(3.14159)=----++++----0 WRITE(A,B) ((1,2),J=3,4,5) WRITE(9,*) WRITE(B,A) 007 MIN=.FALSE. .XOR. .NOT ..1. EQ .03 .AND. .NOT. .NOT. NOT. STOP END BLOCK data IMPLICIT NONE COMPLEX*16 C INTEGER ARRAY(35) REAL R COMMON /WOW/ R,ARRAY EQUIVALENCE (R,C) DATA (ARRAY(I),I=1,5)/5*7/ END END END C This is finally the end of this absurdity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve,
That is just wonderful; perhaps too much for a T shirt or a gravestone, but certainly worthy of framing and displaying in a home office, now where did I put that pile of fanfold?
Thanks
Norman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>This was written by Stan Rabinowitz at DEC in the 1980s...
Great guy, Stan. I worked with him in the 1970's in building 12 at DEC in Maynard.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page