Topic: Error identification

I got the following fatal errors repeating in the new code identified by the Simply Fortran IDE:

Error: PUBLIC statement at (1) is only allowed in the specification part of the module
Error: Syntax error in PRIVATE statement at (1)
Error: Component at (1) must have the POINTER attribute

Would you have any clues as to how I should interpret these?

Re: Error identification

The first two are related to where the public and private keywords are being incorrectly used.  This Stackoverflow question shows a quick example of how to properly use them.

For the third error, you might have to provide some code (example code only if you prefer) or simple context as to why it is occurring.  Are you calling a function that requires a pointer?  We'll just need to learn more.

Jeff Armstrong
Approximatrix, LLC

Re: Error identification

Jeff,
Thanks for your reply.  Since compiling, actually I wound up realizing that my first pass at the code merge had issues, have now re-done the merge and now those warnings are no longer present but now I have new warnings/errors.  Since this forum post is titled "Error identification" I will post my new questions here..

A brief explanation of my project: I am working on the Energy Plus simulation engine module for modeling phase change materials V8.1. I am taking code that is an enhanced phase change model that was developed for V6 and merging to V8.1.  I am working in a three pane text editor merging the enhanced PCM variables, functions and code blocks into the subroutines for V8.1. 

New question(s),  I wonder if there is a difference in compiler errors in red vs not in red?

Some of the new errors do not make much sense because they are directly conflicting with the working code, in the example below does it seem that the compiler warnings should be addressed, or is it just warning about issues that can be ignored?

I added the flag '-x f95-cpp-input ' with the goal of stopping the compiler from complaining about code that should work and '-fmax-errors=0' to get the compiler to not stop at 25 warnings/errors.  Still I get errors and the compiler does not build a binary.  Also some messages seem to be less human readable that expected.  Are these flags being used correctly?

Below is the compiler messages and below that is my code.. If anyone has any tips I would be very greatful.

    "C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -c -o "build\HeatBalFiniteDifferenceManager.o" -g  -cpp -ffree-line-length-none -x f95-cpp-input -fmax-errors=0  -Jmodules ".\HeatBalFiniteDifferenceManager.f90"
.\HeatBalFiniteDifferenceManager.f90:522.58:

  CHARACTER(len=MaxNameLength), DIMENSION(4) :: AlphaNameP
                                                          1
Error: Symbol 'alphanamep' at (1) already has basic type of CHARACTER
.\HeatBalFiniteDifferenceManager.f90:523.57:

  INTEGER                                    :: NumAlphaP
                                                         1
Error: Symbol 'numalphap' at (1) already has basic type of INTEGER
.\HeatBalFiniteDifferenceManager.f90:524.59:

  INTEGER                                    :: NumObjectsP
                                                           1
Error: Symbol 'numobjectsp' at (1) already has basic type of INTEGER
.\HeatBalFiniteDifferenceManager.f90:532.29:

        DO Loop=1,NumObjectsP
                             1
.\HeatBalFiniteDifferenceManager.f90:492.19:

    DO Loop=1,vcMat
                   2
Error: Variable 'loop' at (1) cannot be redefined inside loop beginning at (2)
.\HeatBalFiniteDifferenceManager.f90:573.23:

    DO Loop=1,CondFDMat
                       1
.\HeatBalFiniteDifferenceManager.f90:492.19:

    DO Loop=1,vcMat
                   2
Error: Variable 'loop' at (1) cannot be redefined inside loop beginning at (2)
.\HeatBalFiniteDifferenceManager.f90:661.27:

        DO Loop=1,CondFDMat
                           1
.\HeatBalFiniteDifferenceManager.f90:492.19:

    DO Loop=1,vcMat
                   2
Error: Variable 'loop' at (1) cannot be redefined inside loop beginning at (2)
.\HeatBalFiniteDifferenceManager.f90:785.3:

END SUBROUTINE GetCondFDInput
   1
Error: Expecting END DO statement at (1)
.\HeatBalFiniteDifferenceManager.f90:787:

SUBROUTINE InitHeatBalFiniteDiff
1
Error: Unclassifiable statement at (1)
.\HeatBalFiniteDifferenceManager.f90:805.46:

  USE DataInterfaces, ONLY:SetupOutputVariable
                                              1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:806.50:

  USE DataSurfaces, ONLY: HeatTransferModel_CondFD
                                                  1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:808.77:

IMPLICIT NONE    ! Enforce explicit typing of all variables in this routine
                                                                           1
Error: Unexpected IMPLICIT NONE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:820.43:

  LOGICAL,SAVE        :: MyEnvrnFlag=.TRUE.
                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:821.20:

  INTEGER :: SurfNum
                    1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:822.40:

  INTEGER :: ConstrNum    ! Loop counter
                                        1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:823.24:

  LOGICAL :: errorsFound
                        1
Error: Symbol 'errorsfound' at (1) already has basic type of LOGICAL
.\HeatBalFiniteDifferenceManager.f90:895.3:

END SUBROUTINE InitHeatBalFiniteDiff
   1
Error: Expecting END DO statement at (1)
.\HeatBalFiniteDifferenceManager.f90:898:

SUBROUTINE InitialInitHeatBalFiniteDiff
1
Error: Unclassifiable statement at (1)
.\HeatBalFiniteDifferenceManager.f90:917.56:

  USE General,      ONLY : TrimSigDigits, RoundSigDigits
                                                        1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:918.51:

  USE DataSurfaces, ONLY : HeatTransferModel_CondFD
                                                   1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:919.81:

DataHeatBalance, Only: HighDiffusivityThreshold, ThinMaterialLayerThreshold
                                                                           1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:921.74:

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
                                                                          1
Error: Unexpected IMPLICIT NONE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:936.38:

  Logical,Save :: OneTimeFlag = .true.
                                      1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:937.16:

  INTEGER :: Lay
                1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:938.20:

  INTEGER :: SurfNum
                    1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:939.41:

  CHARACTER(len=MaxNameLength) :: LayChar
                                         1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:941.112:

! Intermediate calculation of nodal spacing. This is the full dx. There is
                                                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:943.128:

ntermediate calculation for number of full thickness nodes per layer. There
                                                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:945.38:

  INTEGER :: Layer      ! Loop counter
                                      1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:946.81:

GER :: OutwardMatLayerNum ! layer index, layer outward of the current layer
                                                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:947.22:

  INTEGER :: layerNode
                      1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:948.17:

  INTEGER :: Delt
                 1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:949.40:

  INTEGER :: ConstrNum    ! Loop counter
                                        1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:950.40:

  INTEGER :: TotNodes     ! Loop counter
                                        1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:951.40:

  INTEGER :: CurrentLayer ! Loop counter
                                        1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:952.40:

  INTEGER :: Surf         ! Loop counter
                                        1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:953.41:

  INTEGER :: index        ! Loop Counters
                                         1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:955.20:

  REAL(r64) :: Alpha
                    1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:956.21:

  REAL(r64) :: Malpha
                     1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:957.28:

  REAL(r64) :: stabilitytemp
                            1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:958.29:

  REAL(r64) :: stabilitymoist
                             1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:959.16:

  REAL(r64) :: a
                1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:960.16:

  REAL(r64) :: b
                1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:961.16:

  REAL(r64) :: c
                1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:962.16:

  REAL(r64) :: d
                1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:963.17:

  REAL(r64) :: kt
                 1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:964.19:

  REAL(r64) :: RhoS
                   1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:965.18:

  REAL(r64) :: Por
                  1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:966.17:

  REAL(r64) :: Cp
                 1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:967.17:

  REAL(r64) :: Dv
                 1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:968.24:

  LOGICAL :: errorsFound
                        1
Error: Symbol 'errorsfound' at (1) already has basic type of LOGICAL
.\HeatBalFiniteDifferenceManager.f90:969.91:

eltaTimestep      ! zone timestep in seconds, for local check of properties
                                                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:970.107:

d ! min thickness consistent with other thermal properties, for local check
                                                                           1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1384.3:

END SUBROUTINE InitialInitHeatBalFiniteDiff
   1
Error: Expecting END DO statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1386:

SUBROUTINE CalcHeatBalFiniteDiff(Surf,TempSurfInTmp,TempSurfOutTmp)
1
Error: Unclassifiable statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1413.44:

  USE General,         ONLY : RoundSigDigits
                                            1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1414.47:

  USE DataHeatBalance, ONLY : CondFDRelaxFactor
                                               1
Error: Unexpected USE statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1415.47:

  USE DataGlobals,     ONLY : KickOffSimulation
                                          at (1)
.\HeatBalFiniteDifferenceManager.f90:1442.15:

  INTEGER  :: J
               1
Error: Unexpected data declaration statement at (1)
.\HeatBalFiniteDifferenceManager.f90:1443.17:

  INTEGER  :: Lay
                 1
Error: Urstt
SD)htrI)        rnrnr2


E s .FfMf0
UNce1              1
Error: Unexpected ELSE statement at (1)
.\HeatBce:UEeC(,uTvoT,l
E:abaa
tifoe HnBDeer:6elc L.  \ieiecn.004
IGRiine)4 .: E:a
    rnttlotta s1aii7E4TO r tf dun           
p acasm
alifer:8r:avDWd oi ll
             rUca     
:eacitmt)\Btfce:5 L  l!n i         
Uthr,\era.7
    CTt)
       1rTu,HlCeLC           
:p c         
rxe     EUtTU\aien.0(ai((e ets*)  r Iia93
(,, taMcoMSHu) 0      rUtA Oea
tning:   rtfo(iieenr019
  T)aSepiMMuemiD  rmt)vaie.1 I- gar  ogt(Heef
OIEeoBn
oxiEOt,   eenn)trg
)R! CPREEA
           
6DI,T)h!ie1  pra
          rUe r mt
Hlt oeaifee:3
(  ptP      1oxd r ra e
alDeM.84
   sgrt)        rUcA Nm )anfee:I   rndMN t)aifcg046
ae 
rpSNIt=         oxd)      edM
IF1ue,Hl,HqM             rUcTNCse .Bifee:6      eeit           1oeeT -Fta
aiina94
     hatSI
         I),M2tStPptdOn Drcitt
nfee:4 IEfpt llisi      1 xte      rptrta\g3

xd eaf5
rii:eup      1 e9.
L    1t1
         redl m(ate::A   1,C e 4:3204.4: 6 STo       E edettn(Hlea:R0 iM9 4S   Eedata\FiM90E 1 ttg3
r ale \l6hn, il     xuyelIl   
mnaiu
BifMf   agTee)
   aFne:3     anea=          rntTFNa(
icr8:     O h          oec EFIta
HlDea.:2:        ahMaaI-     T
       x    .inr53
DcuaDaetCeLC       r1v(HtCan r8:   seet
     
rpTF (eifaf5:(Hs 
) )Ficr7
   seat-       1oxSNOm Hien07   han
   1Hennn     
rntTFOt
tniee:8:(es T)n(cs )             rtSEtI1aeg8
  hO    refoticiHnfcg0.
,T eptCe       
eETf1
atTn ei(            Ed         -n1ee::Dc1,,t,aP      1een.5
T u2CHd       
oTTe HlDeg36
eanI(vpr*)        rp )         ox NTa
tiea.1
   PhMlt2       
ox EFNn1ainaf02
  ShaTr>E    reeatt aPSetiM                    rdFt een9:,,u aCt
    :       
rpSEN neM.0    Pr       
rntTFNtt \BAoMes Bia4
e*E r        r TNNe1eFina93
     Calc  rcTU m nfa9
   )        EndEN e(\Ffn:1 aiIh  (gne   
Udt e1atne3
  aMS=      reeMNNt
line4   aig uacoMeti)               :eSENUNtt(\ifnn.4:T  hB    rneTTTNt )eifMr:1   
rp MUNet
tnfcg0(21 .:pti*IEd HaoD)           
:p MUNm .Bifee:6
     eea   ox MFIsn(\aerae4:   ep    be1tnce4 e :ie.i   c u
aiicg01
(cu ,a eiStd
            rneTh           
rUpeTTNUIset(
\BiDrMe93:SeTt*TeM6
          1rx EUNet)eFtira.42:(HTs )R-SHroI
                  E eATIat1eFDea93
,),M2l ei eu)   f  e)tn5           EUtOta1Hl9dcq2                rntTTI,       E xtdSMTNOtma1\aliDfeae.:62
         PsnMeate)0               e:SatrarHSaPeu     reSECta.lDc9.
    Cat     )
Eae)           rntA N m .Bnirn9.
Hn2In3d STATEMENT FUNCTION statement at (1)
.\HeatBalFiniteDifferenceManager.f90:4829.18Seai2T(f0 iee4:R4S:Tn:e dh           
:d      1rxa Iet :t te(aira4
cae da(ol        1 eenmn t\icr034:o     1rpaa mt
Bir0
L :TM     1rpdctaa
DeeUse .Biea.2:   hatSI       
rxdMtnfee:6
     sgra       dFNe )anfeager.f9
  Pnn(
     rUxtTNNtnt
tieMg01
alpoCcu  Mteo(              reeETst1eFfce2
TFFae,onTTTa )tta2:  ra i c
aiee:2aT  eSSMHu)       1a)ATice:1
TcuaDMcl eu)            E eSEN mt
tieMr52 PaeR
   E:aefc ueHBFeee94.:
   T(dllNau 20e*xRs
    1o e   )eFDne5:rNI  u itCL
           E cta am .BieMr52R6t                                            1
Error: Unexpected data declaration statement at (1)
.\HeatBalFi       
rxd r e H6 :a      oeeaanea
aiina94
L   
     
:p dase .Bifee59R6 
:5561.52:

  INTEGER, INTENT(IN)   :: SurfNum  ! surface number
                   Er
* Complete *

CODE EXAMPLE BELOW HERE:
MODULE HeatBalFiniteDiffManager

          ! Module containing the heat balance simulation routines

          ! MODULE INFORMATION:
          !       AUTHOR         Richard J. Liesen
          !       DATE WRITTEN   October 2003
          !       RE-ENGINEERED  Curtis Pedersen, 2006, Changed to Implicit FD calc for conduction.
          !                      and included enthalpy formulations for phase change materials
          ! PURPOSE OF THIS MODULE:
          ! To encapsulate the data and algorithms required to
          ! manage the fiite difference heat balance simulation on the building.

          ! METHODOLOGY EMPLOYED:
          !

          ! REFERENCES:
          ! The MFD moisture balance method
          !  C. O. Pedersen, Enthalpy Formulation of conduction heat transfer problems
          !    involving latent heat, Simulation, Vol 18, No. 2, February 1972

          ! OTHER NOTES:
          !
          !

          ! USE STATEMENTS:
          ! Use statements for data only modules
USE DataPrecisionGlobals
USE DataGlobals, Only:MaxNameLength,KelvinConv,outputfiledebug, NumOfTimeStepInHour,DisplayExtraWarnings,   &
                      TimeStepZone,Hourofday,TimeStep,OutputFileInits,BeginEnvrnFlag,DayofSim,WarmupFlag,SecInHour
USE DataInterfaces
USE DataMoistureBalance
USE DataHeatBalance, Only: Material, TotMaterials,MaxLayersInConstruct, QRadThermInAbs,Construct,      &
                           TotConstructs,UseCondFD,RegularMaterial,Air,Zone
USE DataHeatBalSurface, Only: NetLWRadToSurf, QRadSWOutAbs, QRadSWInAbs,QRadSWOutMvIns, TempSource, &
                         OpaqSurfInsFaceConductionFlux,OpaqSurfOutsideFaceConductionFlux,  &
                         OpaqSurfOutsideFaceConduction,QsrcHist,OpaqSurfInsFaceConduction,  &
                         QdotRadOutRepPerArea,MinSurfaceTempLimit,MaxSurfaceTempLimit,QdotRadNetSurfInRep,QRadNetSurfInReport
Use DataSurfaces, Only: Surface, TotSurfaces,Ground,SurfaceClass_Window, HeatTransferModel_CondFD
Use DataHeatBalFanSys, Only: Mat, ZoneAirHumRat, QHTRadSysSurf, QHWBaseboardSurf, QSteamBaseboardSurf, QElecBaseboardSurf
Use DataEnvironment, Only: SkyTemp, IsRain
USE Psychrometrics , Only:PsyRhFnTdbRhovLBnd0C,PsyWFnTdbRhPb,PsyHgAirFnWTdb
  ! Fan system Source/Sink heat value, and source/sink location temp from CondFD
USE DataHeatBAlFanSys,  ONLY: QRadSysSource,TCondFDSourceNode,QPVSysSource
USE HeatBalanceMovableInsulation,  ONLY : EvalOutsideMovableInsulation

IMPLICIT NONE   ! Enforce explicit typing of all variables

PRIVATE   !Make everything private except what is specifically Public

          ! MODULE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: Lambda=2500000.0d0
REAL(r64), PARAMETER :: smalldiff=1.d-8  ! Used in places where "equality" tests should not be used.

INTEGER, PARAMETER :: CrankNicholsonSecondOrder = 1 ! original CondFD scheme.  semi implicit, second order in time
INTEGER, PARAMETER :: FullyImplicitFirstOrder  = 2 ! fully implicit scheme, first order in time.
CHARACTER(len=*), PARAMETER, DIMENSION(2) :: cCondFDSchemeType=  &
   (/'CrankNicholsonSecondOrder',  &
     'FullyImplicitFirstOrder  '/)

REAL(r64),PARAMETER :: TempInitValue = 23.0d0    ! Initialization value for Temperature
REAL(r64),PARAMETER :: RhovInitValue = 0.0115d0  ! Initialization value for Rhov
REAL(r64),PARAMETER :: EnthInitValue = 100.0d0   ! Initialization value for Enthalpy

          ! DERIVED TYPE DEFINITIONS:
TYPE, PUBLIC ::  ConstructionDataFD
  CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: Name ! Name of construction
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: DelX                 !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TempStability
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: MoistStability

  Integer, ALLOCATABLE, DIMENSION(:) :: NodeNumPoint  !
!  INTEGER, ALLOCATABLE, DIMENSION(:) :: InterfaceNodeNums   ! Layer interfaces occur at these nodes

  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Thickness
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: NodeXlocation ! sized to TotNode, contains X distance in m from outside face
  INTEGER :: TotNodes=0

  Integer :: DeltaTime=0

END TYPE ConstructionDataFD


TYPE, PUBLIC :: SurfaceDataFD
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: T             !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TOld          !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TT
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Rhov          !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: RhovOld       !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: RhoT
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TD            !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TDT            !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TempLastStep
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TDTLast
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TDOld         !
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: TDreport
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Enthreport
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: RH
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: RHreport
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: EnthOld        ! Current node enthalpy
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: EnthNew        ! Node enthalpy at new time
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: EnthLast
  INTEGER                                 :: GSloopCounter = 0 ! count of inner loop iterations
  INTEGER                                 :: GSloopErrorCount = 0 ! recurring error counter
  REAL(r64)                               :: MaxNodeDelTemp = 0.0d0 ! largest change in node temps after calc
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: EnthLastStep

  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: CpOld         !Node Enthalpy at old time
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: CpOld1         !Node Enthalpy at old time
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: CpOld2         !Node Enthalpy at old time for multiple material layer
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Cp_node         !Node Enthalpy at old time
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Cp1_node         !Node Enthalpy at old time for multiple material layer
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: Cp2_node         !Node Enthalpy at old time for multiple material layer 
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: PhaseChangeHeatTransferState         !Flag which determines which curve to use
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: PhaseChangeHeatTransferStateOld         !Flag which determines which curve to use based on PhaseChangeHeatTransferState
                                                                        !(it stores the value of previous timesteps PhaseChangeHeatTransferState) 
  INTEGER,    ALLOCATABLE, DIMENSION(:) :: PhaseChangeTransition
  INTEGER,    ALLOCATABLE, DIMENSION(:) :: PhaseChangeTransitionOld
 
  Integer,        ALLOCATABLE, DIMENSION(:) :: PhaseChangeMaterialState     !-2 liquid, -1 Melting, 0 Transition, 1 Freezing, 2 Solid
                                                                       
  Integer,        ALLOCATABLE, DIMENSION(:) :: PhaseChangeMaterialStateold    ! -2 liquid, -1 Melting, 0 Transition, 1 Freezing, 2 Solid
                                                                        ! of previous timestep
  Integer,        ALLOCATABLE, DIMENSION(:) :: PhaseChangeMaterialStateoldold !-2 liquid, -1 Melting, 0 Transition, 1 Freezing, 2 Solid
                                                                        ! of timestep previous to previous timestep
  REAL(r64),    ALLOCATABLE, DIMENSION(:) :: PhaseChangeTemperatureReverse !Temperature at which the phase changes reverses its direction

END TYPE SurfaceDataFD

TYPE MaterialDataFD
  REAL(r64) :: tk1          =0.0d0  ! Temperature coefficient for thermal conductivity
  INTEGER   :: numTempEnth  = 0   ! number of Temperature/Enthalpy pairs
  INTEGER   :: numTempCond  = 0   ! number of Temperature/Conductivity pairs
  REAL(r64), ALLOCATABLE, DIMENSION(:,:)  :: TempEnth  !  Temperature enthalpy Function Pairs,
                                                       !  TempEnth(1,1)= first Temp, TempEnth(1,2) = First Enthalpy,
                                                       !  TempEnth(2,1) = secomd Temp, etc.
  REAL(r64), ALLOCATABLE, DIMENSION(:,:)  :: TempCond  !  Temperature thermal conductivity Function Pairs,
                                                       !  TempCond(1,1)= first Temp, Tempcond(1,2) = First conductivity,
                                                       !  TempEnth(2,1) = secomd Temp, etc.
END TYPE
          ! MODULE VARIABLE DECLARATIONS:
TYPE (ConstructionDataFD), PUBLIC, ALLOCATABLE, DIMENSION(:) :: ConstructFD
TYPE (SurfaceDataFD), PUBLIC,   ALLOCATABLE, DIMENSION(:) :: SurfaceFD
TYPE (MaterialDataFD), ALLOCATABLE, DIMENSION(:) :: MaterialFD

!REAL(r64) :: TFDout   =0.0d0
!REAL(r64) :: TFDin    =0.0d0
!REAL(r64) :: rhovFDout=0.0d0
!REAL(r64) :: rhovFDin =0.0d0
!REAL(r64) :: TDryout  =0.0d0
!REAL(r64) :: Tdryin   =0.0d0
!REAL(r64) :: RHOut    =0.0d0
!REAL(r64) :: RHIn     =0.0d0

REAL(r64) :: TempTlowPCM          =0.0d0    !temperature at which the phase change of PCM starts
REAL(r64) :: TempThighPCM         =0.0d0    !temperature at which the phase change of PCM ends
REAL(r64) :: SpecHeatSolidPCM     !specific heat of PCM in solid state
REAL(r64) :: SpecHeatLiquidPCM     !specific heat of PCM in liquid state
REAL(r64)         :: Tau1
REAL(r64)         :: Tau2
REAL(r64)         :: DeltaH
REAL(r64)         :: TcM
REAL(r64)         :: Tau1F
REAL(r64)         :: Tau2F
REAL(r64)         :: TcF
REAL(r64)         :: Tc
REAL(r64)         :: TcOld
REAL(r64), ALLOCATABLE, DIMENSION(:) :: SigmaR      !  Total Resistance of construction layers
REAL(r64), ALLOCATABLE, DIMENSION(:) :: SigmaC      !  Total Capacitance of construction layers

!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: WSurfIn         !Humidity Ratio of the inside surface for reporting
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QMassInFlux     !MassFlux on Surface for reporting
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QMassOutFlux    !MassFlux on Surface for reporting
REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QHeatInFlux     !HeatFlux on Surface for reporting
REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QHeatOutFlux    !HeatFlux on Surface for reporting
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QFluxZoneToInSurf !sum of Heat flows at the surface to air interface,
!                                 ! zone-side boundary conditions W/m2 before CR 8280 was not reported, but was calculated.
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QFluxOutsideToOutSurf !sum of Heat flows at the surface to air interface, Out-side boundary conditions W/m2
!                                                           ! before CR 8280 was
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QFluxInArrivSurfCond !conduction between surface node and first node into the surface (sensible)
!                                                           ! before CR 8280 was -- Qdryin    !HeatFlux on Surface for reporting for Sensible only
!REAL(r64), ALLOCATABLE, DIMENSION(:)   :: QFluxOutArrivSurfCond  !HeatFlux on Surface for reporting for Sensible only
!                                                                 ! before CR 8280 -- Qdryout         !HeatFlux on Surface for reporting for Sensible only
INTEGER :: PCMalgorithm = 0 ! 0 for Simple curve fit
                             ! Type of the PCM algorithm selected default is 'Simple curve fit'
                         
INTEGER :: PCMModel = 0 ! 0 for transition behaviour of PCM
                             ! Type of the PCM algorithm selected default is 'Transition'

INTEGER   :: CondFDSchemeType = FullyImplicitFirstOrder  ! solution scheme for CondFD - default
REAL(r64) :: SpaceDescritConstant = 3.d0 ! spatial descritization constant,
REAL(r64) :: MinTempLimit = -100.d0 ! lower limit check, degree C
REAL(r64) :: MaxTempLimit =  100.d0 ! upper limit check, degree C
!feb2012 INTEGER   :: MaxGSiter = 200  ! maximum number of Gauss Seidel iterations
INTEGER   :: MaxGSiter = 30  ! maximum number of Gauss Seidel iterations
REAL(r64) :: fracTimeStepZone_Hour=0.0d0
LOGICAL   :: GetHBFiniteDiffInputFlag=.true.
INTEGER :: WarmupSurfTemp=0
          ! Subroutine Specifications for the Heat Balance Module
          ! Driver Routines
PUBLIC  ManageHeatBalFiniteDiff

          ! Initialization routines for module
PUBLIC  InitHeatBalFiniteDiff
PRIVATE GetCondFDInput

          ! Algorithms for the module
PRIVATE CalcHeatBalFiniteDiff
PRIVATE ExteriorBCEqns
PRIVATE InteriorBCEqns
PRIVATE terpld
PRIVATE InteriorNodeEqns
PRIVATE IntInterfaceNodeEqns
PRIVATE SpecEnthalpy

          ! Reporting routines for module
PRIVATE ReportFiniteDiffInits

          ! Update Data Routine
PUBLIC  UpdateMoistureBalanceFD


CONTAINS

! MODULE SUBROUTINES:
!*************************************************************************
SUBROUTINE ManageHeatBalFiniteDiff(SurfNum,TempSurfInTmp,TempSurfOutTmp)
          ! SUBROUTINE INFORMATION:
          !       AUTHOR         Richard Liesen
          !       DATE WRITTEN   May 2000
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! This subroutine manages the moisture balance method.  It is called
          ! from the HeatBalanceManager at the time step level.
          ! This driver manages the calls to all of
          ! the other drivers and simulation algorithms.

          ! METHODOLOGY EMPLOYED:
          ! na

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:

  IMPLICIT NONE    ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS
  Integer, Intent(In) :: SurfNum
  REAL(r64), Intent(InOut) :: TempSurfInTmp       !INSIDE SURFACE TEMPERATURE OF EACH HEAT TRANSFER SURF.
  REAL(r64), Intent(InOut) :: TempSurfOutTmp      !Outside Surface Temperature of each Heat Transfer Surface

          ! DERIVED TYPE DEFINITIONS
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  LOGICAL,SAVE :: GetInputFlag=.true.

          ! FLOW:

  ! Get the moisture balance input at the beginning of the simulation only
  IF (GetHBFiniteDiffInputFlag) THEN
      ! Obtains conduction FD related parameters from input file
    CALL GetCondFDInput
    GetHBFiniteDiffInputFlag=.false.
  ENDIF

  ! Condition is taken care of by calling routine:
  ! IF (Surface(SurfNum)%HeatTransSurf .and. Surface(SurfNum)%Class /= SurfaceClass_Window)

  ! Solve the zone heat & moisture balance using a finite difference solution
  CALL CalcHeatBalFiniteDiff(SurfNum,TempSurfInTmp,TempSurfOutTmp)

  RETURN

END SUBROUTINE ManageHeatBalFiniteDiff


! Get Input Section of the Module
!******************************************************************************
SUBROUTINE GetCondFDInput
          ! SUBROUTINE INFORMATION:
          !       AUTHOR         Curtis Pedersen
          !       DATE WRITTEN   July 2006
          !       MODIFIED       Brent Griffith Mar 2011, user settings
          !
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! This subroutine is the main driver for initializations for the variable property CondFD part of the
          ! MFD algorithm

          ! METHODOLOGY EMPLOYED:
          ! na

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE DataIPShortCuts
  USE InputProcessor, ONLY: GetNumObjectsFound,GetObjectItem,FindItemInList
  USE DataHeatBalance, ONLY: MaxAllowedDelTempCondFD, CondFDRelaxFactor, CondFDRelaxFactorInput
  USE General, ONLY: RoundSigDigits

  IMPLICIT NONE    ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
            ! na
          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS
          ! na

          ! DERIVED TYPE DEFINITIONS
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  INTEGER :: IOStat           ! IO Status when calling get input subroutine
  CHARACTER(len=MaxNameLength),DIMENSION(3) &
          :: MaterialNames ! Number of Material Alpha names defined
  CHARACTER(len=MaxNameLength),DIMENSION(3)  :: ConstructionName ! Name of Construction with CondFDsimplified
  INTEGER :: MaterNum         ! Counter to keep track of the material number
  INTEGER :: MaterialNumAlpha ! Number of material alpha names being passed
  INTEGER :: MaterialNumProp  ! Number of material properties being passed
  REAL(r64), DIMENSION(40) :: MaterialProps !Temporary array to transfer material properties
  REAL(r64), DIMENSION(10) :: PCMProps !Temporary array to transfer PCM properties
  LOGICAL :: ErrorsFound = .false. ! If errors detected in input
!  INTEGER :: CondFDMat                ! Number of variable property CondFD materials in input
  INTEGER :: ConstructNumber     ! Cconstruction with CondHBsimple to be overridden with CondHBdetailed
  INTEGER :: TotHBAlgorithmOverrideConstructs  ! Number of constructions where HBAlgoSimplified will be overriddem with detailed.

  INTEGER :: NumConstructionAlpha
  Integer :: Loop
  INTEGER :: NumAlphas
  INTEGER :: NumNumbers
  INTEGER :: propNum
  INTEGER :: pcount
  INTEGER :: pcMat
  INTEGER :: vcMat
  INTEGER :: inegptr
  LOGICAL :: nonInc
!--------------------------------------------------------------------------------------------------------------------
!JCDBUG PHASE CHANGE ANALYTICAL BELOW
  CHARACTER(len=MaxNameLength), DIMENSION(4) :: AlphaNameP
  INTEGER                                    :: NumAlphaP
  INTEGER                                    :: NumObjectsP


  ! user settings for numerical parameters
  cCurrentModuleObject = 'HeatBalanceSettings:ConductionFiniteDifference'

  IF (GetNumObjectsFound(cCurrentModuleObject) > 0) THEN
    CALL GetObjectItem(cCurrentModuleObject,1,cAlphaArgs,NumAlphas, &
                       rNumericArgs,NumNumbers,IOSTAT,  &
                   AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                   AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)

    IF (.NOT. lAlphaFieldBlanks(1)) THEN

      SELECT CASE (cAlphaArgs(1))

      CASE ('CRANKNICHOLSONSECONDORDER')
        CondFDSchemeType = CrankNicholsonSecondOrder
      CASE ('FULLYIMPLICITFIRSTORDER')
        CondFDSchemeType = FullyImplicitFirstOrder
      CASE DEFAULT
        CALL ShowSevereError(TRIM(cCurrentModuleObject)//': invalid '//TRIM(cAlphaFieldNames(1))//  &
         ' entered='//TRIM(cAlphaArgs(1))//', must match CrankNicholsonSecondOrder or FullyImplicitFirstOrder.')
        ErrorsFound=.true.
      END SELECT

    ENDIF

    IF (.NOT. lNumericFieldBlanks(1)) THEN
      SpaceDescritConstant = rNumericArgs(1)
    ENDIF
    IF (.NOT. lNumericFieldBlanks(2)) THEN
      CondFDRelaxFactorInput = rNumericArgs(2)
      CondFDRelaxFactor      = CondFDRelaxFactorInput
    ENDIF
    IF (.NOT. lNumericFieldBlanks(3)) THEN
      MaxAllowedDelTempCondFD = rNumericArgs(3)
    ENDIF

  ENDIF ! settings object

  pcMat=GetNumObjectsFound('MaterialProperty:PhaseChange')
  vcMat=GetNumObjectsFound('MaterialProperty:VariableThermalConductivity')

  ALLOCATE(MaterialFD(TotMaterials))

  ! Load the additional CondFD Material properties
  cCurrentModuleObject='MaterialProperty:PhaseChange'    ! Phase Change Information First

  IF ( pcMat .NE. 0 ) Then                      !  Get Phase Change info
!    CondFDVariableProperties = .TRUE.
    DO Loop=1,pcMat

    !Call Input Get routine to retrieve material data
      CALL GetObjectItem(cCurrentModuleObject,Loop,MaterialNames,MaterialNumAlpha, &
                       MaterialProps,MaterialNumProp,IOSTAT,  &
                   AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                   AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)


    !Load the material derived type from the input data.
      MaterNum = FindItemInList(MaterialNames(1),Material%Name,TotMaterials)
      IF (MaterNum == 0) THEN
        CALL ShowSevereError(TRIM(cCurrentModuleObject)//': invalid '//TRIM(cAlphaFieldNames(1))//  &
           ' entered='//TRIM(MaterialNames(1))//', must match to a valid Material name.')
        ErrorsFound=.true.
        Cycle
      ENDIF

      IF (Material(MaterNum)%Group /= RegularMaterial) THEN
        CALL ShowSevereError(TRIM(cCurrentModuleObject)//  &
           ': Reference Material is not appropriate type for CondFD properties, material='//  &
           TRIM(Material(MaterNum)%Name)//', must have regular properties (L,Cp,K,D)')
        ErrorsFound=.true.
      ENDIF


    ! Once the material derived type number is found then load the additional CondFD variable material properties
    !   Some or all may be zero (default).  They will be checked when calculating node temperatures
      MaterialFD(MaterNum)%tk1          = MaterialProps(1)
      MaterialFD(MaterNum)%numTempEnth  = (MaterialNumProp-1)/2
      IF (MaterialFD(MaterNum)%numTempEnth*2 /= (MaterialNumProp-1)) THEN
        CALL ShowSevereError('GetCondFDInput: '//trim(cCurrentModuleObject)//'="'//trim(MaterialNames(1))//  &
           '", mismatched pairs')
        CALL ShowContinueError('...expected '//trim(RoundSigDigits(MaterialFD(MaterNum)%numTempEnth))//  &
           ' pairs, but only entered '//trim(RoundSigDigits(MaterialNumProp-1))//' numbers.')
        ErrorsFound=.true.
      ENDIF
      ALLOCATE(MaterialFD(MaterNum)%TempEnth(MaterialFD(MaterNum)%numTempEnth,2))
      MaterialFD(MaterNum)%TempEnth     =0.0d0
      propNum=2
      ! Temperature first
      DO pcount=1,MaterialFD(MaterNum)%numTempEnth
        MaterialFD(MaterNum)%TempEnth(pcount,1)   = MaterialProps(propNum)
        propNum=propNum+2
      ENDDO
      propNum=3
      ! Then Enthalpy
      DO pcount=1,MaterialFD(MaterNum)%numTempEnth
        MaterialFD(MaterNum)%TempEnth(pcount,2)   = MaterialProps(propNum)
        propNum=propNum+2
      ENDDO
      nonInc=.false.
      inegptr=0
      DO pcount=1,MaterialFD(MaterNum)%numTempEnth-1
        IF (MaterialFD(MaterNum)%TempEnth(pcount,1) < MaterialFD(MaterNum)%TempEnth(pcount+1,1)) CYCLE
        nonInc=.true.
        inegptr=pcount+1
        EXIT
      ENDDO
      IF (nonInc) THEN
        CALL ShowSevereError('GetCondFDInput: '//trim(cCurrentModuleObject)//'="'//trim(MaterialNames(1))//  &
           '", non increasing Temperatures. Temperatures must be strictly increasing.')
        CALL ShowContinueError('...occurs first at item=['//trim(RoundSigDigits(inegptr))//'], value=['//  &
           trim(RoundSigDigits(MaterialFD(MaterNum)%TempEnth(inegptr,1),2))//'].')
        ErrorsFound=.true.
      ENDIF
      nonInc=.false.
      inegptr=0
      DO pcount=1,MaterialFD(MaterNum)%numTempEnth-1
        IF (MaterialFD(MaterNum)%TempEnth(pcount,2) <= MaterialFD(MaterNum)%TempEnth(pcount+1,2)) CYCLE
        nonInc=.true.
        inegptr=pcount+1
        EXIT
      ENDDO
      IF (nonInc) THEN
        CALL ShowSevereError('GetCondFDInput: '//trim(cCurrentModuleObject)//'="'//trim(MaterialNames(1))//  &
           '", non increasing Enthalpy.')
        CALL ShowContinueError('...occurs first at item=['//trim(RoundSigDigits(inegptr))//'], value=['//  &
           trim(RoundSigDigits(MaterialFD(MaterNum)%TempEnth(inegptr,2),2))//'].')
        CALL ShowContinueError('...These values may be Cp (Specific Heat) rather than Enthalpy.  Please correct.')
        ErrorsFound=.true.
      ENDIF
    ENDDO
  END IF
!   Get CondFD Variable Thermal Conductivity Input

  cCurrentModuleObject='MaterialProperty:VariableThermalConductivity'    ! Variable Thermal Conductivity Info next
  IF ( vcMat .NE. 0 ) Then   !  variable k info
!    CondFDVariableProperties = .TRUE.
    DO Loop=1,vcMat

      !Call Input Get routine to retrieve material data
      CALL GetObjectItem(cCurrentModuleObject,Loop,MaterialNames,MaterialNumAlpha, &
                       MaterialProps,MaterialNumProp,IOSTAT,  &
                   AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                   AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)


      !Load the material derived type from the input data.
      MaterNum = FindItemInList(MaterialNames(1),Material%Name,TotMaterials)
      IF (MaterNum == 0) THEN
        CALL ShowSevereError(TRIM(cCurrentModuleObject)//': invalid '//TRIM(cAlphaFieldNames(1))//  &
         ' entered='//TRIM(MaterialNames(1))//', must match to a valid Material name.')
        ErrorsFound=.true.
        Cycle
      ENDIF

      IF (Material(MaterNum)%Group /= RegularMaterial) THEN
        CALL ShowSevereError(TRIM(cCurrentModuleObject)//  &
           ': Reference Material is not appropriate type for CondFD properties, material='//  &
           TRIM(Material(MaterNum)%Name)//', must have regular properties (L,Cp,K,D)')
        ErrorsFound=.true.
      ENDIF


    ! Once the material derived type number is found then load the additional CondFD variable material properties
    !   Some or all may be zero (default).  They will be checked when calculating node temperatures
!JCDBUG PHASE CHANGE ANALYTICAL BELOW
!--------------------------------------------------------------------------------------------------------------------
!JCDBUG G-FORTRAN COMPILER
  !JCDBUG CHARACTER(len=MaxNameLength), DIMENSION(4) :: AlphaNameP !Error: Symbol 'alphanamep' at (1) already has basic type of CHARACTER 523.57:
  !JCDBUG INTEGER :: NumAlphaP !Error: Symbol 'numalphap' at (1) already has basic type of INTEGER 524.59:
  !JCDBUG INTEGER :: NumObjectsP  !Error: Symbol 'numobjectsp' at (1) already has basic type of INTEGER 532.29:

   cCurrentModuleObject='PhaseChangeMaterialSettings'

   NumObjectsP=GetNumObjectsFound(TRIM(cCurrentModuleObject))
   
    IF (NumObjectsP > 0) THEN
       
        DO Loop=1,NumObjectsP
       
                CALL GetObjectItem(TRIM(cCurrentModuleObject),Loop,AlphaNameP,MaterialNumAlpha, &
                       MaterialProps,MaterialNumProp,IOSTAT,  &
                   AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                   AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)

                SELECT CASE (AlphaNameP(1))
                 CASE ('SIMPLECURVEFIT')
                   PCMalgorithm = 0
                 CASE ('HYSTERESIS')
                   PCMalgorithm = 1
                 CASE DEFAULT
                   PCMalgorithm = 0
                   AlphaNameP(1) = 'SIMPLECURVEFIT'
                   CALL ShowWarningError(TRIM(cCurrentModuleObject)//': Invalid input of '//TRIM(cAlphaFieldNames(1))//  &
                      '. The default choice assigned is '//TRIM(AlphaNameP(1)))
                   CALL ShowContinueError('Valid choices are: SimpleCurveFit or  Hysteresis')
                END SELECT

                SELECT CASE (AlphaNameP(2))
                 CASE ('TRANSITION')
                   PCMModel = 0
                 CASE ('NON-TRANSITION')
                   PCMModel = 1
                 CASE DEFAULT
                   PCMModel = 0
                   AlphaNameP(2) = 'TRANSITION'
                   CALL ShowWarningError(TRIM(cCurrentModuleObject)//': Invalid input of '//TRIM(cAlphaFieldNames(2))//  &
                      '. The default choice assigned is '//TRIM(AlphaNameP(2)))
                   CALL ShowContinueError('Valid choices are: Transition, Non-Transition.')
                END SELECT
        END DO
    END IF
!-------------------------------------------------------------------------------------------------------------------------

  ! Load the additional CondFD Material properties
  cCurrentModuleObject='MaterialProperty:PhaseChange'    ! Phase Change Information First
  CondFDMat=GetNumObjectsFound(TRIM(cCurrentModuleObject))

  IF ( CondFDMat .NE. 0 ) Then                      !  Get Phase Change info
    DO Loop=1,CondFDMat

    !Call Input Get routine to retrieve material data
    CALL GetObjectItem(TRIM(cCurrentModuleObject),Loop,MaterialNames,MaterialNumAlpha, &
                       MaterialProps,MaterialNumProp,IOSTAT,  &
                   AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                   AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)


    !Load the material derived type from the input data.
    MaterNum = FindItemInList(MaterialNames(1),Material%Name,TotMaterials)
    IF (MaterNum == 0) THEN
      CALL ShowSevereError(TRIM(cCurrentModuleObject)//': invalid '//TRIM(cAlphaFieldNames(1))//  &
         ' entered='//TRIM(MaterialNames(1))//', must match to a valid Material name.')
      ErrorsFound=.true.
      Cycle
    ENDIF

    IF (Material(MaterNum)%Group /= RegularMaterial) THEN
      CALL ShowSevereError(TRIM(cCurrentModuleObject)//  &
         ': Reference Material is not appropriate type for CondFD properties, material='//  &
         TRIM(Material(MaterNum)%Name)//', must have regular properties (L,Cp,K,D)')
      ErrorsFound=.true.
    ENDIF



    ! Once the material derived type number is found then load the additional CondFD variable material properties
    !   Some or all may be zero (default).  They will be checked when calculating node temperatures

   
    Material(MaterNum)%tk1                        =     MaterialProps(1)                                                                                                       
    Material(MaterNum)%TempLowPCM                =     MaterialProps(2)                                                                                                       
    Material(MaterNum)%TempHighPCM                =     MaterialProps(3)
    Material(MaterNum)%TempEnth(1,1)            =     MaterialProps(4)                                                                                                           
    Material(MaterNum)%TempEnth(1,2)            =     MaterialProps(5)                                                                                                                   
    Material(MaterNum)%TempEnth(2,1)            =     MaterialProps(6)                                                                                                                   
    Material(MaterNum)%TempEnth(2,2)            =     MaterialProps(7)                                                                                                                   
    Material(MaterNum)%TempEnth(3,1)            =     MaterialProps(8)                                                                                                                   
    Material(MaterNum)%TempEnth(3,2)            =     MaterialProps(9)                                                                                                                   
    Material(MaterNum)%TempEnth(4,1)            =     MaterialProps(10)                                                                                                                   
    Material(MaterNum)%TempEnth(4,2)            =     MaterialProps(11)                                                                                                                   
    Material(MaterNum)%TempEnth(5,1)            =     MaterialProps(12)                                                                                                                   
    Material(MaterNum)%TempEnth(5,2)            =     MaterialProps(13)                                                                                                                   
    Material(MaterNum)%TempEnth(6,1)            =     MaterialProps(14)                                                                                                                   
    Material(MaterNum)%TempEnth(6,2)            =     MaterialProps(15)                                                                                                                   
    Material(MaterNum)%blank3                    =     MaterialProps(16)    !This value is not used anywhere                                                                                                               
    Material(MaterNum)%blank4                    =     MaterialProps(17)    !This value is not used anywhere                                                                                                   
    Material(MaterNum)%TempEnthMelting(1,1)        =     MaterialProps(18)                                                                                                           
    Material(MaterNum)%TempEnthMelting(1,2)        =     MaterialProps(19)                                                                                                               
    Material(MaterNum)%TempEnthMelting(2,1)        =     MaterialProps(20)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(2,2)        =     MaterialProps(21)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(3,1)        =     MaterialProps(22)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(3,2)        =     MaterialProps(23)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(4,1)        =     MaterialProps(24)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(4,2)        =     MaterialProps(25)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(5,1)        =     MaterialProps(26)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(5,2)        =     MaterialProps(27)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(6,1)        =     MaterialProps(28)                                                                                                                   
    Material(MaterNum)%TempEnthMelting(6,2)        =     MaterialProps(29)                                                                                                                   
    Material(MaterNum)%blank5                    =     MaterialProps(30)    !This value is not used anywhere                                                                                                               
    Material(MaterNum)%blank6                    =     MaterialProps(31)    !This value is not used anywhere                                                                                           
    Material(MaterNum)%TempEnthFreezing(1,1)    =     MaterialProps(32)                                                                                                   
    Material(MaterNum)%TempEnthFreezing(1,2)    =     MaterialProps(33)                                                                                                               
    Material(MaterNum)%TempEnthFreezing(2,1)    =     MaterialProps(34)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(2,2)    =     MaterialProps(35)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(3,1)    =     MaterialProps(36)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(3,2)    =     MaterialProps(37)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(4,1)    =     MaterialProps(38)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(4,2)    =     MaterialProps(39)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(5,1)    =     MaterialProps(40)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(5,2)    =     MaterialProps(41)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(6,1)    =     MaterialProps(42)
    Material(MaterNum)%TempEnthFreezing(6,2)    =     MaterialProps(43)                                                                                                                   
    Material(MaterNum)%blank7                    =     MaterialProps(44)    !This value is not used anywhere                                                                                                               
    Material(MaterNum)%blank8                    =     MaterialProps(45)    !This value is not used anywhere                                                                               
    Material(MaterNum)%TempEnthCrystallizationPoint(1,1)    =    MaterialProps(46)                                                                                       
    Material(MaterNum)%TempEnthCrystallizationPoint(1,2)    =    MaterialProps(47)                                                                                                               


   ENDDO
  END IF
 
!******************************************************************************************************************************
    cCurrentModuleObject='MaterialProperty:PhaseChangeAnalytical'    ! Phase Change Information First
    CondFDMat=GetNumObjectsFound(TRIM(cCurrentModuleObject))

    IF ( CondFDMat .NE. 0 ) Then                      !  Get Phase Change info
        DO Loop=1,CondFDMat

            !Call Input Get routine to retrieve material data
            CALL GetObjectItem(TRIM(cCurrentModuleObject),Loop,MaterialNames,MaterialNumAlpha, &
                                MaterialProps,MaterialNumProp,IOSTAT,  &
                            AlphaBlank=lAlphaFieldBlanks,NumBlank=lNumericFieldBlanks,  &
                            AlphaFieldnames=cAlphaFieldNames,NumericFieldNames=cNumericFieldNames)

            MaterNum = FindItemInList(MaterialNames(1),Material%Name,TotMaterials)
            IF (MaterNum == 0) THEN
                CALL ShowSevereError(TRIM(cCurrentModuleObject)//': invalid '//TRIM(cAlphaFieldNames(1))//  &
                     ' entered='//TRIM(MaterialNames(1))//', must match to a valid Material name.')
                  ErrorsFound=.true.
                CYCLE
            ENDIF

            IF (Material(MaterNum)%Group /= RegularMaterial) THEN
              CALL ShowSevereError(TRIM(cCurrentModuleObject)//  &
                 ': Reference Material is not appropriate type for CondFD properties, material='//  &
                 TRIM(Material(MaterNum)%Name)//', must have regular properties (L,Cp,K,D)')
              ErrorsFound=.true.
            ENDIF
           
         Material(MaterNum)%tk1        =     MaterialProps(1)       
          Material(MaterNum)%DeltaHF    =     MaterialProps(2)   
          Material(MaterNum)%DeltaHS    =     MaterialProps(3)
          Material(MaterNum)%CpSolid    =     MaterialProps(4)
          Material(MaterNum)%CpLiquid    =     MaterialProps(5)
          Material(MaterNum)%Tm            =     MaterialProps(6)
          Material(MaterNum)%Tf         =     MaterialProps(7)
          Material(MaterNum)%Tau1       =     MaterialProps(8)
          Material(MaterNum)%Tau2       =     MaterialProps(9)
          Material(MaterNum)%Tau1Prime    =     MaterialProps(10)
          Material(MaterNum)%Tau2Prime    =     MaterialProps(11)
         
          IF(PCMAlgorithm==0) THEN
              IF(MaterialProps(2) /= MaterialProps(3)) THEN
                MaterialProps(3) = MaterialProps(2) 
                Material(MaterNum)%DeltaHS = MaterialProps(3)
                CALL ShowWarningError(TRIM(cCurrentModuleObject)//': Invalid input of '//TRIM(cNumericFieldNames(3))//  &
                    '. The default choice assigned is '//TRIM(cNumericFieldNames(2)))
                CALL ShowContinueError('Melting properties assigned to freezing properties')
              END IF
             
             IF(MaterialProps(6) /= MaterialProps(7)) THEN
                 MaterialProps(7) = MaterialProps(6)
                 Material(MaterNum)%Tf = MaterialProps(6)
                 Material(MaterNum)%Tau1Prime    =     MaterialProps(8)
                 Material(MaterNum)%Tau2Prime    =     MaterialProps(9)                 
                CALL ShowWarningError(TRIM(cCurrentModuleObject)//': Invalid input for '//TRIM(cNumericFieldNames(7))//  &
                    '. The default choice assigned is '//TRIM(cNumericFieldNames(6)))
                CALL ShowContinueError('Melting properties assigned to freezing properties')
            END IF
          ELSE IF(PCMAlgorithm==1) THEN
              IF(MaterialProps(6) == MaterialProps(7)) THEN
                CALL ShowSevereError(TRIM(cCurrentModuleObject)//  &
                ': Freezing Temperature equal to Melting Temperature, material='//  &
                TRIM(Material(MaterNum)%Name)//', must have different values, PCM Algorithm = '//TRIM(AlphaNameP(1))//' Model')
                ErrorsFound=.true.
              END IF
          END IF
!JCDBUG PHASE CHANGE BELOW

      MaterialFD(MaterNum)%numTempCond  = MaterialNumProp/2
      IF (MaterialFD(MaterNum)%numTempCond*2 /= MaterialNumProp) THEN
        CALL ShowSevereError('GetCondFDInput: '//trim(cCurrentModuleObject)//'="'//trim(MaterialNames(1))//  &
           '", mismatched pairs')
        CALL ShowContinueError('...expected '//trim(RoundSigDigits(MaterialFD(MaterNum)%numTempCond))//  &
           ' pairs, but only entered '//trim(RoundSigDigits(MaterialNumProp))//' numbers.')
        ErrorsFound=.true.
      ENDIF
      ALLOCATE(MaterialFD(MaterNum)%TempCond(MaterialFD(MaterNum)%numTempCond,2))
      MaterialFD(MaterNum)%TempCond    =0.0d0
      propNum=1
      ! Temperature first
      DO pcount=1,MaterialFD(MaterNum)%numTempCond
        MaterialFD(MaterNum)%TempCond(pcount,1)   = MaterialProps(propNum)
        propNum=propNum+2
      ENDDO
      propNum=2
      ! Then Conductivity
      DO pcount=1,MaterialFD(MaterNum)%numTempCond
        MaterialFD(MaterNum)%TempCond(pcount,2)   = MaterialProps(propNum)
        propNum=propNum+2
      ENDDO
      nonInc=.false.
      inegptr=0
      DO pcount=1,MaterialFD(MaterNum)%numTempCond-1
        IF (MaterialFD(MaterNum)%TempCond(pcount,1) < MaterialFD(MaterNum)%TempCond(pcount+1,1)) CYCLE
        nonInc=.true.
        inegptr=pcount+1
        EXIT
      ENDDO
      IF (nonInc) THEN
        CALL ShowSevereError('GetCondFDInput: '//trim(cCurrentModuleObject)//'="'//trim(MaterialNames(1))//  &
           '", non increasing Temperatures. Temperatures must be strictly increasing.')
        CALL ShowContinueError('...occurs first at item=['//trim(RoundSigDigits(inegptr))//'], value=['//  &
           trim(RoundSigDigits(MaterialFD(MaterNum)%TempCond(inegptr,1),2))//'].')
        ErrorsFound=.true.
      ENDIF
    ENDDO
  END IF

  DO MaterNum=1,TotMaterials
    IF (MaterialFD(MaterNum)%numTempEnth == 0) THEN
      MaterialFD(MaterNum)%numTempEnth=3
      ALLOCATE(MaterialFD(MaterNum)%TempEnth(MaterialFD(MaterNum)%numTempEnth,2))
      MaterialFD(MaterNum)%TempEnth=-100.0d0
    ENDIF
    IF (MaterialFD(MaterNum)%numTempCond == 0) THEN
      MaterialFD(MaterNum)%numTempCond=3
      ALLOCATE(MaterialFD(MaterNum)%TempCOnd(MaterialFD(MaterNum)%numTempCond,2))
      MaterialFD(MaterNum)%TempCond=-100.0d0
    ENDIF
ENDDO

  IF (ErrorsFound) THEN
    CALL ShowFatalError('GetCondFDInput: Errors found getting ConductionFiniteDifference properties. Program terminates.')
  ENDIF

  CALL InitialInitHeatBalFiniteDiff

  RETURN

END SUBROUTINE GetCondFDInput

SUBROUTINE InitHeatBalFiniteDiff

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         Richard J. Liesen
          !       DATE WRITTEN   Oct 2003
          !       MODIFIED       na
          !       RE-ENGINEERED  C O Pedersen 2006
          !                      B. Griffith May 2011 move begin-environment and every-timestep inits, cleanup formatting

         ! PURPOSE OF THIS SUBROUTINE:
          ! This subroutine sets the initial values for the FD moisture calculation

          ! METHODOLOGY EMPLOYED:

          ! REFERENCES:
          !

          ! USE STATEMENTS:
  USE DataInterfaces, ONLY:SetupOutputVariable
  USE DataSurfaces, ONLY: HeatTransferModel_CondFD

  IMPLICIT NONE    ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS
          ! na

          ! DERIVED TYPE DEFINITIONS
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  LOGICAL,SAVE        :: MyEnvrnFlag=.TRUE.
  INTEGER :: SurfNum
  INTEGER :: ConstrNum    ! Loop counter
  LOGICAL :: errorsFound

  IF (GetHBFiniteDiffInputFlag) THEN
      ! Obtains conduction FD related parameters from input file
    CALL GetCondFDInput
    GetHBFiniteDiffInputFlag=.false.
  ENDIF

  errorsFound=.false.

  ! now do begin environment inits.
  IF (BeginEnvrnFlag .AND. MyEnvrnFlag) THEN
    DO SurfNum=1,TotSurfaces
      IF (Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_CondFD)   CYCLE
      IF(Surface(SurfNum)%Construction <= 0) CYCLE  ! Shading surface, not really a heat transfer surface
      ConstrNum=Surface(SurfNum)%Construction
      IF(Construct(ConstrNum)%TypeIsWindow) CYCLE  !  Windows simulated in Window module
      SurfaceFD(SurfNum)%T              = TempInitValue
      SurfaceFD(SurfNum)%TOld           = TempInitValue
      SurfaceFD(SurfNum)%TT             = TempInitValue
      SurfaceFD(SurfNum)%Rhov           = RhovInitValue
      SurfaceFD(SurfNum)%RhovOld        = RhovInitValue
      SurfaceFD(SurfNum)%RhoT           = RhovInitValue
      SurfaceFD(SurfNum)%TD             = TempInitValue
      SurfaceFD(SurfNum)%TDT            = TempInitValue
      SurfaceFD(SurfNum)%TDTLast        = TempInitValue
      SurfaceFD(SurfNum)%TDOld          = TempInitValue
      SurfaceFD(SurfNum)%TDreport       = TempInitValue
      SurfaceFD(SurfNum)%RH             = 0.0d0
      SurfaceFD(SurfNum)%RHreport       = 0.0d0
      SurfaceFD(SurfNum)%EnthOld        = EnthInitValue
      SurfaceFD(SurfNum)%EnthNew        = EnthInitValue
      SurfaceFD(SurfNum)%EnthLast       = EnthInitValue

      TempOutsideAirFD(SurfNum)         = 0.d0
      RhoVaporAirOut(SurfNum)           = 0.d0
      RhoVaporSurfIn(SurfNum)           = 0.d0
      RhoVaporAirIn(SurfNum)            = 0.d0
      HConvExtFD(SurfNum)               = 0.d0
      HMassConvExtFD(SurfNum)           = 0.d0
      HConvInFD(SurfNum)                = 0.d0
      HMassConvInFD(SurfNum)            = 0.d0
      HSkyFD(SurfNum)                   = 0.d0
      HGrndFD(SurfNum)                  = 0.d0
      HAirFD(SurfNum)                   = 0.d0
    ENDDO
    WarmupSurfTemp=0
    MyEnvrnFlag = .FALSE.
  END IF
  IF (.NOT. BeginEnvrnFlag) THEN
    MyEnvrnFlag=.TRUE.
  ENDIF

  ! now do every timestep inits

  DO SurfNum=1,TotSurfaces
    IF (Surface(SurfNum)%HeatTransferAlgorithm /= HeatTransferModel_CondFD)  CYCLE
    IF(Surface(SurfNum)%Construction <= 0) CYCLE  ! Shading surface, not really a heat transfer surface
    ConstrNum=Surface(SurfNum)%Construction
    IF(Construct(ConstrNum)%TypeIsWindow) CYCLE  !  Windows simulated in Window module
    SurfaceFD(SurfNum)%T        = SurfaceFD(SurfNum)%TOld
    SurfaceFD(SurfNum)%Rhov     = SurfaceFD(SurfNum)%RhovOld
    SurfaceFD(SurfNum)%TD       = SurfaceFD(SurfNum)%TDOld
    SurfaceFD(SurfNum)%TDT      = SurfaceFD(SurfNum)%TDreport !PT changes from TDold to TDreport
    SurfaceFD(SurfNum)%TDTLast  = SurfaceFD(SurfNum)%TDOld
    SurfaceFD(SurfNum)%EnthOld  = SurfaceFD(SurfNum)%EnthOld
    SurfaceFD(SurfNum)%EnthNew  = SurfaceFD(SurfNum)%EnthOld
    SurfaceFD(SurfNum)%EnthLast = SurfaceFD(SurfNum)%EnthOld
  ENDDO

  RETURN

END SUBROUTINE InitHeatBalFiniteDiff


SUBROUTINE InitialInitHeatBalFiniteDiff

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         Linda Lawrie
          !       DATE WRITTEN   March 2012
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! This routine performs the original allocate, inits and setup output variables for the
          ! module.

          ! METHODOLOGY EMPLOYED:
          ! na

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE General,      ONLY : TrimSigDigits, RoundSigDigits
  USE DataSurfaces, ONLY : HeatTransferModel_CondFD
  USE DataHeatBalance, Only: HighDiffusivityThreshold, ThinMaterialLayerThreshold

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
          ! na

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  Logical,Save :: OneTimeFlag = .true.
  INTEGER :: Lay
  INTEGER :: SurfNum
  CHARACTER(len=MaxNameLength) :: LayChar

  REAL(r64)             :: dxn        ! Intermediate calculation of nodal spacing. This is the full dx. There is
                                                  ! a half dxn thick node at each surface. dxn is the "capacitor" spacing.
  INTEGER                           :: ipts1      ! Intermediate calculation for number of full thickness nodes per layer. There
                                                  ! are always two half nodes at the layer faces.
  INTEGER :: Layer      ! Loop counter
  INTEGER :: OutwardMatLayerNum ! layer index, layer outward of the current layer
  INTEGER :: layerNode
  INTEGER :: Delt
  INTEGER :: ConstrNum    ! Loop counter
  INTEGER :: TotNodes     ! Loop counter
  INTEGER :: CurrentLayer ! Loop counter
  INTEGER :: Surf         ! Loop counter
  INTEGER :: index        ! Loop Counters

  REAL(r64) :: Alpha
  REAL(r64) :: Malpha
  REAL(r64) :: stabilitytemp
  REAL(r64) :: stabilitymoist
  REAL(r64) :: a
  REAL(r64) :: b
  REAL(r64) :: c
  REAL(r64) :: d
  REAL(r64) :: kt
  REAL(r64) :: RhoS
  REAL(r64) :: Por
  REAL(r64) :: Cp
  REAL(r64) :: Dv
  LOGICAL :: errorsFound
  REAL(r64) :: DeltaTimestep      ! zone timestep in seconds, for local check of properties

Re: Error identification

It appears you do have some syntax errors.  I can't speak to them specifically at this time (I'm away from my desk this week).  Is there any chance that the variables named "alphanamep" and others are already declared in other modules in your project?

I'll take a more detailed look at your source next week when I return.

Jeff Armstrong
Approximatrix, LLC

Re: Error identification

Jeff,
Thank you kindly for your advise. I have made it much farther in my project, have resolved lots of the issues in this post and have a new and much smaller problem.  I get the following error messages:

"C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -c -o "build\HeatBalFiniteDifferenceManager.o" -g  -cpp -ffree-line-length-none  -Jmodules ".\HeatBalFiniteDifferenceManager.f90"
.\HeatBalFiniteDifferenceManager.f90:672.68:

    Material(MaterNum)%TempEnthFreezing(5,2)    =     MaterialProps(41)       
                                                                    1
Warning: Array reference at (1) is out of bounds (41 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:673.68:

    Material(MaterNum)%TempEnthFreezing(6,1)    =     MaterialProps(42)
                                                                    1
Warning: Array reference at (1) is out of bounds (42 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:674.68:

    Material(MaterNum)%TempEnthFreezing(6,2)    =     MaterialProps(43)       
                                                                    1
Warning: Array reference at (1) is out of bounds (43 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:675.69:

    Material(MaterNum)%blank7                    =     MaterialProps(44)    !Th
                                                                     1
Warning: Array reference at (1) is out of bounds (44 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:676.69:

    Material(MaterNum)%blank8                    =     MaterialProps(45)    !Th
                                                                     1
Warning: Array reference at (1) is out of bounds (45 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:677.79:

Material(MaterNum)%TempEnthCrystallizationPoint(1,1)    =    MaterialProps(46)
                                                                           1
Warning: Array reference at (1) is out of bounds (46 > 40) in dimension 1
.\HeatBalFiniteDifferenceManager.f90:678.79:

Material(MaterNum)%TempEnthCrystallizationPoint(1,2)    =    MaterialProps(47)
                                                                           1
For the following code:

   Material(MaterNum)%TempEnthFreezing(5,2)    =     MaterialProps(41)                                                                                                                   
    Material(MaterNum)%TempEnthFreezing(6,1)    =     MaterialProps(42)
    Material(MaterNum)%TempEnthFreezing(6,2)    =     MaterialProps(43)                                                                                                                   
    Material(MaterNum)%blank7                    =     MaterialProps(44)    !This value is not used anywhere                                                                                                               
    Material(MaterNum)%blank8                    =     MaterialProps(45)    !This value is not used anywhere                                                                               
    Material(MaterNum)%TempEnthCrystallizationPoint(1,1)    =    MaterialProps(46)                                                                                       
    Material(MaterNum)%TempEnthCrystallizationPoint(1,2)    =    MaterialProps(47)                                                                                                               

The issue is that I do not see any problem with the code...

Any ideas?

Many thanks

Re: Error identification

The error you're seeing is due to indexing elements of an array beyond the bounds of that array.  Looking in the original HeatBalFiniteDifferenceManager.f90, I can see that it is declared as:

  REAL(r64), DIMENSION(40) :: MaterialProps !Temporary array to transfer material properties

In your code, you are attempting to access values beyond the maximum index of 40.  The compiler has detected this, and it is issuing an error. 

You might need to simply enlarge the MaterialProps array to accommodate the additional entries.

Jeff Armstrong
Approximatrix, LLC

Re: Error identification

Jeff,
Thanks, and solved. I got my code working, now on to debug!