style-cleaned the extracted input reader.

This commit is contained in:
2026-06-18 15:07:16 +02:00
parent d075ce5cee
commit 1f3fd44f98
+95 -78
View File
@@ -554,9 +554,9 @@ C=======================================================================
C This part reads the input file (new format).
C The JavaScript/Electron frontend writes this sequential block layout,
C so the READ order below must stay in sync with CreateInpFile().
C Input reading has been moved to READ_GUI_INPUT so the
C Input reading has been moved to readGuiInput so the
C GUI file layout is isolated from the transport code.
CALL READ_GUI_INPUT(INNAM,ERRNAM,Z1,M1,E0,ESIG,ALPHA,ALPHASIG,EF,
call readGuiInput(INNAM,ERRNAM,Z1,M1,E0,ESIG,ALPHA,ALPHASIG,EF,
& ESB,SHEATH,ERC,NH,RI,RI2,RI3,X0,RD,CW,CA,KK0,KK0R,KDEE1,
& KDEE2,IPOT,IPOTR,IRL,NLayers,CHEM,DX,RHO,CK,NJ,ZT,MT,CO,SBE,
& ED,BE,CH1,CH2,CH3,CH4,CH5)
@@ -4766,88 +4766,105 @@ C
C=======================================================================
C READ GUI-GENERATED INPUT FILE
C=======================================================================
SUBROUTINE READ_GUI_INPUT(INNAM,ERRNAM,Z1,M1,E0,ESIG,ALPHA,
& ALPHASIG,EF,ESB,SHEATH,ERC,NH,RI,RI2,RI3,X0,RD,CW,CA,KK0,
& KK0R,KDEE1,KDEE2,IPOT,IPOTR,IRL,NLayers,CHEM,DX,RHO,CK,NJ,ZT,
& MT,CO,SBE,ED,BE,CH1,CH2,CH3,CH4,CH5)
IMPLICIT NONE
INTEGER MAXNL,MAXEL
PARAMETER (MAXNL=60)
PARAMETER (MAXEL=12)
CHARACTER*(*) INNAM,ERRNAM
CHARACTER*50 CHEM(MAXNL)
INTEGER I,J,NLAYERS,NH
INTEGER*4 KK0,KK0R,KDEE1,KDEE2,IPOT,IPOTR,IRL
INTEGER*4 NJ(MAXNL)
REAL*8 Z1,M1,E0,ESIG,ALPHA,ALPHASIG
REAL*8 EF,ESB,SHEATH,ERC
REAL*8 RI,RI2,RI3,X0,RD,CW,CA
REAL*8 DX(MAXNL),RHO(MAXNL),CK(MAXNL)
REAL*8 ZT(MAXNL,MAXEL),MT(MAXNL,MAXEL)
REAL*8 CO(MAXNL,MAXEL),SBE(MAXNL,MAXEL)
REAL*8 ED(MAXNL,MAXEL),BE(MAXNL,MAXEL)
REAL*8 CH1(MAXNL,MAXEL),CH2(MAXNL,MAXEL)
REAL*8 CH3(MAXNL,MAXEL),CH4(MAXNL,MAXEL)
REAL*8 CH5(MAXNL,MAXEL)
OPEN(UNIT=99,file=errnam,STATUS='replace')
OPEN(UNIT=11,file=innam,STATUS='unknown',ERR=1359)
subroutine readGuiInput(inputName,errorName,projectileZ,
& projectileMass,initialEnergy,energySigma,incidentAngle,
& angleSigma,cutoffEnergy,surfaceBarrier,sheathPotential,
& recoilCutoff,nProjectiles,seed1,seed2,seed3,initialDepth,
& randomDepth,depthBinWidth,collisionAccuracy,primaryMode,
& recoilMode,stoppingPrimary,stoppingRecoil,potentialPrimary,
& potentialRecoil,recoilLayerMode,nLayers,chem,layerThickness,
& layerDensity,correctionFactor,nElements,atomicNumber,
& atomicMass,concentration,surfaceBinding,displacementEnergy,
& bulkBinding,
& zieglerA1,zieglerA2,zieglerA3,zieglerA4,zieglerA5)
implicit none
integer maxNl,maxEl
parameter (maxNl=60)
parameter (maxEl=12)
character*(*) inputName,errorName
character*50 chem(maxNl)
integer i,j,nLayers,nProjectiles
integer*4 primaryMode,recoilMode,stoppingPrimary,stoppingRecoil
integer*4 potentialPrimary,potentialRecoil,recoilLayerMode
integer*4 nElements(maxNl)
real*8 projectileZ,projectileMass,initialEnergy,energySigma
real*8 incidentAngle,angleSigma
real*8 cutoffEnergy,surfaceBarrier,sheathPotential,recoilCutoff
real*8 seed1,seed2,seed3,initialDepth,randomDepth
real*8 depthBinWidth,collisionAccuracy
real*8 layerThickness(maxNl),layerDensity(maxNl)
real*8 correctionFactor(maxNl)
real*8 atomicNumber(maxNl,maxEl),atomicMass(maxNl,maxEl)
real*8 concentration(maxNl,maxEl),surfaceBinding(maxNl,maxEl)
real*8 displacementEnergy(maxNl,maxEl),bulkBinding(maxNl,maxEl)
real*8 zieglerA1(maxNl,maxEl),zieglerA2(maxNl,maxEl)
real*8 zieglerA3(maxNl,maxEl),zieglerA4(maxNl,maxEl)
real*8 zieglerA5(maxNl,maxEl)
open(unit=99,file=errorName,status='replace')
open(unit=11,file=inputName,status='unknown',err=1359)
C First line: properties of projectile
C Ordered as: Z, mass number (amu), imp. energy, dist. of imp. energy, angle, dist. angles,
READ(11,*) Z1,M1,E0,Esig,ALPHA,ALPHASIG,EF,ESB,SHEATH,ERC
C Ordered as: Z, mass number (amu), imp. energy, dist. of imp.
C energy, angle, dist. angles.
read(11,*) projectileZ,projectileMass,initialEnergy,energySigma,
& incidentAngle,angleSigma,cutoffEnergy,surfaceBarrier,
& sheathPotential,recoilCutoff
C Second line: simulation related parameters
C Ordered as: Number of particles, seed, seed, seed, initial depth, RD, depth increment, CA, KK0, KDEE1,KDEE2,IPOT
READ(11,*) NH,RI,RI2,RI3,X0,RD,CW,CA,KK0,KK0R,KDEE1,KDEE2,IPOT
& ,IPOTR,IRL
C Third line: Number of layers
read(11,66) NLayers
C Ordered as: number of particles, seeds, initial depth, RD, depth
C increment, CA, KK0, KDEE1, KDEE2, IPOT.
read(11,*) nProjectiles,seed1,seed2,seed3,initialDepth,
& randomDepth,depthBinWidth,collisionAccuracy,primaryMode,
& recoilMode,stoppingPrimary,stoppingRecoil,potentialPrimary,
& potentialRecoil,recoilLayerMode
C Third line: number of layers
read(11,66) nLayers
66 format(9x,I4)
IF(NLayers.LT.1.OR.NLayers.GT.MAXNL) THEN
WRITE(99,*) 'ERROR: number of layers out of range: ',NLayers
WRITE(99,*) 'Valid range is 1..',MAXNL
WRITE(*,*) 'ERROR: number of layers out of range: ',NLayers
STOP
ENDIF
C Here we read the NLayers structure
DO I=1,NLayers
C Chemical formula (chem), Thickness (DX), density (RHO), and correction factor
C (CK, it is always 1.0??), number of elements (nel)
C Possibly add the number of elements in the layer
READ(11,*) chem(I),DX(I),RHO(I),CK(I),NJ(I)
IF(NJ(I).LT.1.OR.NJ(I).GT.MAXEL) THEN
WRITE(99,*) 'ERROR: elements in layer out of range'
WRITE(99,*) 'Layer, NJ, MAXEL = ',I,NJ(I),MAXEL
WRITE(*,*) 'ERROR: elements in layer out of range'
WRITE(*,*) 'Layer, NJ, MAXEL = ',I,NJ(I),MAXEL
STOP
ENDIF
C Replace the following lines with read(11,*) (a(i,j), j = 1, 5)
if(nLayers.lt.1.or.nLayers.gt.maxNl) then
write(99,*) 'ERROR: number of layers out of range: ',nLayers
write(99,*) 'Valid range is 1..',maxNl
write(*,*) 'ERROR: number of layers out of range: ',nLayers
stop
endif
C Read the layer structure.
do i=1,nLayers
C Chemical formula, thickness, density, correction factor, and
C number of elements.
read(11,*) chem(i),layerThickness(i),layerDensity(i),
& correctionFactor(i),nElements(i)
if(nElements(i).lt.1.or.nElements(i).gt.maxEl) then
write(99,*) 'ERROR: elements in layer out of range'
write(99,*) 'Layer, NJ, MAXEL = ',i,nElements(i),maxEl
write(*,*) 'ERROR: elements in layer out of range'
write(*,*) 'Layer, NJ, MAXEL = ',i,nElements(i),maxEl
stop
endif
C Atomic numbers
read(11,*) (ZT(I,j), j = 1, NJ(I))
read(11,*) (atomicNumber(i,j), j = 1, nElements(i))
C Mass numbers (amu)
read(11,*) (MT(I,j), j = 1, NJ(I))
C Concentration (stoichiometry)
read(11,*) (CO(I,j), j = 1, NJ(I))
read(11,*) (atomicMass(i,j), j = 1, nElements(i))
C Concentration fractions
read(11,*) (concentration(i,j), j = 1, nElements(i))
C Surface binding energy
read(11,*) (SBE(I,j), j = 1, NJ(I))
C Displacement energy, always 30 eV??
read(11,*) (ED(I,j), j = 1, NJ(I))
C Bulk binding energy, usually zero
read(11,*) (BE(I,j), j = 1, NJ(I))
C value A-1 of the ziegler tables
read(11,*) (CH1(I,j), j = 1, NJ(I))
C value A-2 of the ziegler tables
read(11,*) (CH2(I,j), j = 1, NJ(I))
C value A-3 of the ziegler tables
read(11,*) (CH3(I,j), j = 1, NJ(I))
C value A-4 of the ziegler tables
read(11,*) (CH4(I,j), j = 1, NJ(I))
C value A-5 of the ziegler tables
read(11,*) (CH5(I,j), j = 1, NJ(I))
ENDDO
1359 CLOSE(UNIT=11)
RETURN
END
read(11,*) (surfaceBinding(i,j), j = 1, nElements(i))
C Displacement energy
read(11,*) (displacementEnergy(i,j), j = 1, nElements(i))
C Bulk binding energy
read(11,*) (bulkBinding(i,j), j = 1, nElements(i))
C Ziegler table coefficient A1
read(11,*) (zieglerA1(i,j), j = 1, nElements(i))
C Ziegler table coefficient A2
read(11,*) (zieglerA2(i,j), j = 1, nElements(i))
C Ziegler table coefficient A3
read(11,*) (zieglerA3(i,j), j = 1, nElements(i))
C Ziegler table coefficient A4
read(11,*) (zieglerA4(i,j), j = 1, nElements(i))
C Ziegler table coefficient A5
read(11,*) (zieglerA5(i,j), j = 1, nElements(i))
enddo
1359 close(unit=11)
return
end
C=======================================================================
C UTILITY SUBROUTINES AND FUNCTIONS
C=======================================================================