View previous topic :: View next topic |
Author |
Message |
MarzAttax
Joined: 15 Jun 2006 Posts: 46
|
Posted: Thu Mar 14, 2013 7:11 pm Post subject: Compiler issues? |
|
|
Hi there,
If I have Modules:
!<=================================================
Module Whatever_hdr
Type stWhatever
Type-Whatever :: iBovvered
EndType stWhatever
End Module Whatever_hdr
!>=================================================
!<=================================================
Module Spots_hdr
!! Modules
USE Whatever_hdr !! stWhatever
Type stSpots
Integer*4 :: iVariable
Type(stWhatever) :: pstWhatever
EndType stSpots
End Module Spots_hdr
!>=================================================
!<=================================================
Module Spots
IMPLICIT NONE
Contains
!=================================================
Logical*4 Function Spots_Func(pstSpotsP)
!! Modules
USE Spots_hdr !! stSpots
!! Passed
Type(stSpots), INTENT(INOUT) :: pstSpotsP
!! Locals
Logical*4 bNoErrorL, bEverthingOkL
bEverthingOkL = .FALSE.
Do
Do something with pstSpots perhaps
bEverthingOkL = .TRUE.
Exit
Enddo
Spots_Func = bEverthingOkL
End Function Spots_Func
!=================================================
End Module Spots
!>=================================================
!<=================================================
Module Leopard_hdr
!! Modules
USE Spots_hdr !! stSpots
Type stLeopard
Integer*4 :: iCount
Integer*4 :: iEnd
Type(stSpots), Pointer :: ptrSpots
EndType stLeopard
End Module Leopard_hdr
!>=================================================
!<=================================================
Module Leopard
IMPLICIT NONE
Contains
!! Modules
USE Leopard_hdr !! stLeopard
!! Declarations
Type(stLeopard), Private :: pstLeopardM
!=================================================
Logical*4 Function Leopard_Func1(pstSpotsP)
!! Modules
USE Spots !! Spots_Func
!! Passed
Type(stProject), Target :: pstSpotsP
!! Locals
Logical*4 bNoErrorL, bEverthingOkL
bEverthingOkL = .FALSE.
Do
pstLeopardM%ptrSpots => pstSpotsP
a) bNoErrorL = Spots_Func(pstSpotsP)
If(.NOT.bNoErrorL) Exit
b) bNoErrorL = Spots_Func(pstLeopardM%ptrSpots)
If(.NOT.bNoErrorL) Exit
bEverthingOkL = .TRUE.
Exit
Enddo
Leopard_Func1 = bEverthingOkL
End Function Leopard_Func1
!=================================================
!=================================================
Logical*4 Function Leopard_Func2()
!! Locals
Logical*4 bNoErrorL, bEverthingOkL
bEverthingOkL = .FALSE.
Do
Do pstLeopardM%iCount = 1, pstLeopardM%iEnd
Do something (with Exit condition), or even do nothing, makes no odds
Enddo
bEverthingOkL = .TRUE.
Exit
Enddo
Leopard_Func2 = bEverthingOkL
End Function Leopard_Func2
!=================================================
Subroutine Leopard_New()
pstLeopardM%iCount = -1
pstLeopardM%iEnd = -1
NULLIFY(pstLeopardM%pstSpots)
End Subroutine Leopard_New
!=================================================
End Module Leopard
!>=================================================
Assuming I have the above pseudo-code correct (hope y'all get the idea) and
Leopard_New has been called and all other structures etc have been initialised etc, then:
If I use (a) this gives: Error 15, Attempt to access undefined argument to routine
If I use (b) then no such error occurs and carries on ...
Why is this?
In Leopard_Func2, the compiler returns:
error 227 - DO control variables must be INTEGER or REAL scalar variables only
error 52 - Compilation abandoned
However, both iCount and iEnd are Integer*4
I replaced iEnd with a local Integer*4 == still get error.
I replaced iCount with a local Integer*4 and it compiles with no errors.
I swapped the order of iCount and iEnd in stLeopard, but the compiler still complained about iCount.
I have checked spelling, copy-Pasted th |
|
Back to top |
|
|
MarzAttax
Joined: 15 Jun 2006 Posts: 46
|
Posted: Thu Mar 14, 2013 7:17 pm Post subject: ...addendum |
|
|
I swapped the order of iCount and iEnd in stLeopard, but the compiler still complained about iCount.
I have checked spelling, copy-Pasted the structure-name and iCount - all to no avail (
Do you think this anything to do with my post:
Mon Nov 19, 2012 5:31 pm Post subject: The structure of things
to which Paul replied:
Tue Nov 20, 2012 4:30 pm
This is a compiler fault and I have logged it for investigation.
?
In closing I feel the need to say that, over the past years that I have used this IDE I have found "it"
really does not like having modules declared at the start of a module, for example:
Module Leopard
!! Modules
USE Leopard_hdr !! stLeopard
especially if they contain executable code. I have found that if the source-file is "large enough" then
code "far enough" down appears to not "see" these modules and "have" to be declared locally.
It's all rather confusing really.
Why I opted to do so in Leopard is beyond me, a sign of the onset of insanity perhaps Þ
Kinds regards
Marz |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Thu Mar 14, 2013 8:21 pm Post subject: |
|
|
If you were to post a small sample of Fortran code that we could compile and run, then we might be able to offer some positive advice. |
|
Back to top |
|
|
MarzAttax
Joined: 15 Jun 2006 Posts: 46
|
Posted: Fri Mar 15, 2013 2:17 pm Post subject: Ok, try this: |
|
|
ExeMain.f95:
Program ExeMain
USE Leopard !! bLeopard
IMPLICIT NONE
!<<
!=================================================
!=================================================
!<<
!! Locals
Logical*4 :: bNoErrorL
Do
bNoErrorL = bLeopard()
If(.NOT.bNoErrorL) Exit
Exit
Enddo
!>>
!=================================================
!=================================================
!>>
End Program ExeMain
ForTheLoveOfGod_hdr.f95:
Module ForTheLoveOfGod_hdr
Type stForTheLoveOfGod
Integer*4 :: iCount1
Integer*4 :: iNumber1
Integer*4 :: iNumber2
Integer*4 :: iCount2
EndType stForTheLoveOfGod
End Module ForTheLoveOfGod_hdr
Leopard.f95:
Module Leopard
!! Modules
USE ForTheLoveOfGod_hdr !! stForTheLoveOfGodM
IMPLICIT NONE
!! Declarations
Type(stForTheLoveOfGod), Private :: pstForTheLoveOfGodM
Contains
Logical*4 Function bLeopard()
Do pstForTheLoveOfGodM%iNumber1 = 1, pstForTheLoveOfGodM%iCount2
Enddo
End Function bLeopard
End Module Leopard |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Mar 15, 2013 5:25 pm Post subject: |
|
|
You can not use pstForTheLoveOfGodM%iNumber1 as the control variable in the DO loop. It must be a simple integer not a member of a type. |
|
Back to top |
|
|
MarzAttax
Joined: 15 Jun 2006 Posts: 46
|
Posted: Fri Mar 15, 2013 5:38 pm Post subject: Dumbstruck |
|
|
Now why does that not surprise me - this IS Fortran after all.
Well, one learns something new every day.
Thanks for your response Paul. |
|
Back to top |
|
|
|