Silverfrost Forums

Welcome to our forums

Compiler issues?

14 Mar 2013 6:11 #11762

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 Integer4 :: iCount Integer4 :: 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

  1. bNoErrorL = Spots_Func(pstSpotsP) If(.NOT.bNoErrorL) Exit

  2. 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 Integer4 I replaced iEnd with a local Integer4 == 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 the structure-name

14 Mar 2013 6:17 #11763

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

14 Mar 2013 7:21 #11765

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.

15 Mar 2013 1:17 #11773

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 Integer4 :: iCount1 Integer4 :: iNumber1 Integer4 :: iNumber2 Integer4 :: 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

15 Mar 2013 4:25 #11774

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.

15 Mar 2013 4:38 #11775

Now why does that not surprise me - this IS Fortran after all.

Well, one learns something new every day.

Thanks for your response Paul.

Please login to reply.