SUBROUTINE TYPE70(TIME,XIN,OUT,T,DTDT,PAR2,INFO2,ICNTRL,*)
C GROUPED PARAMETER REPLACEMENT UNIT
C Jeff Thornton and David Bradley, July 1998
C
C This component is called only once at the beginning of a simulation.
C It reads some values from a file and then uses these values to
C overwrite some PARAMETERs read from the deck text file. Essentially,
C the purposed of TYPE70 is to allow PARAMETERSs to be read in from disk.
C The TYPE 9 Data Reader performs the same function for INPUTs.
C
C USAGE:
C UNIT XX TYPE 70
C PARAMETERS 3
C LU NPARS UNIT
C INPUTS 0
C
C WHERE:
C LU = Logical unit of file containing parameters
C NPARS = Number of consecutive parameters to be replaced
C UNIT = Unit number to which parameters in fle correspond
C
C FILE STRUCTURE:
C The text file contains a list of the parameters to be replaced in the
C deck. One value (parameter) per line. The parameters MUST BE CONSECUTIVE
C and start with PAR1. You need not provide all parameters, just enough
C to get to the last one being replaced.
C
C************************************************************************
C************************************************************************
INCLUDE '/trnwin/kernal/param.inc'
INTEGER*4 INFO2(15)
DOUBLE PRECISION XIN,OUT
PARAMETER(NTYPMAX=20,NXMAX=200)
REAL XPAR(NTYPMAX,NXMAX),PAR2(1+2*NTYPMAX),HOMIE,HOMIE2,HOMIE3
INTEGER MTYPE(NTYPMAX),PARSINTYPE(NTYPMAX),NREAD(NTYPMAX)
COMMON /LUNITS/ LUR,LUW,IFORM,LUK
COMMON /UNITS/ NUNITS,IUNITS,IDECK(NUNITL),JUNITS,JCALL(NUNITL),
. NDEP(NUNITL),NPAR(NUNITL),NPARAM,PAR(NMPAR),
. INFO(15,NUNITL),TRON(NUNITL),TROFF(NUNITL),ERTOL
ISUNIT=INFO2(1)
IF (INFO2(7).GE.0) RETURN 1
C FIRST CALL OF SIMULATION
INFO2(6)=0
NI=0
ND=0
C SET THE NUMBER OF PARAMETERS TO THAT SPECIFIED IN THE DECK
NP=INFO2(4)
C CALL TYPECK TO CHECK THE NUMBER OF PARS, INPUTS, AND DERIVATIVES
CALL TYPECK(1,INFO2,NI,NP,ND)
C READ THE LOGICAL UNIT WHICH CONTAINS THE PARAMETERS FOR THE UNITS TO BE REPLACED
LU=INT(PAR2(1)+0.1)
C DETERMINE HOW MANY UNITS ARE TO BE REPLACED
NUMUNITS=(NP-1)/2
C GET THE NUMBER OF PARAMETERS TO BE REPLACED FOR EACH UNIT
DO 5 J=1,NUMUNITS
NREAD(J)=INT(PAR2(2+2*(J-1))+0.1)
HOMIE=NREAD(1)
IF(NREAD(J).GT.NXMAX) CALL TYPECK(-4,INFO2,NI,2,ND)
5 CONTINUE
C DETERMINE THE UNIT NUMBERS THAT WILL HAVE THEIR PARAMETERS REPLACED
DO 10 J=1,NUMUNITS
MTYPE(J)=INT(PAR2(3+2*(J-1))+0.1)
HOMIE2=MTYPE(1)
10 CONTINUE
C READ THE VALUES OF THE NEW PARAMETERS FOR EACH OF THE TYPES
REWIND(LU)
DO 20 J=1,NUMUNITS
READ(LU,*,ERR=500, END=500) (XPAR(J,K),K=1,NREAD(J))
HOMIE3=XPAR(1,1)
20 CONTINUE
GOTO 25
C DETERMINE THE SPOT IN THE PARAMETER ARRAY FOR A GIVEN UNIT NUMBER
25 DO 30 J=1,NUMUNITS
PARSINTYPE(J)=INFO(4,MTYPE(J))
ISPOTPAR=NPAR(MTYPE(J))
DO 40 K=1,MIN(PARSINTYPE(J),NREAD(J))
PAR(ISPOTPAR+K-1)=XPAR(J,K)
40 CONTINUE
30 CONTINUE
RETURN 1
500 WRITE(LUW,501) 71,INFO2(1),INFO2(2)
501 FORMAT(//,1X,'***** ERROR *****',8X,'TRNSYS ERROR # ',I3,/1X,
.'UNIT ',I3,' TYPE ',I3,/1X,
.'UNABLE TO CORRECTLY READ THE SPECIFIED DATA FILE')
CALL MYSTOP(71)
END