
C	to compute mode shape, "Full Wave"
C	modivan

C	Sven Ivansson  1992





	SUBROUTINE MODIVAN ( UP, IDMAX,ICMAX )
C	-> note that the system matrix is the same in all "dhcompfw" calls 
C	   (only the right-hand side is different)
C	-> "scaling" of the system might be useful (cf. DBA 5.5.5, but a 
C	   different situation there)

	USE INMODELa
	USE FWYSa

	IMPLICIT NONE

	INCLUDE '../RPPARAMETER.INC'
C       nol <= noldim

	INCLUDE '../INPARAM.INC'
	INCLUDE 'FWINIT.INC'

	COMPLEX*16 UP
	INTEGER IDMAX,ICMAX

	INTEGER ID
	REAL*8 DYSMAX
	COMPLEX*16 YSMAX,YSMAXINV

C	now the main call
	CALL DHIVANFW2 (UP)

	CALL FWYSMAX (IDMAX,ICMAX, DYSMAX,YSMAX)

	IF (DYSMAX.GT.0.0D0) THEN
C	  apply mult scaling so the "idmax,icmax" component becomes 1
	  YSMAXINV = 1/YSMAX
	  DO ID = 0, NOL-1
	    YS2FW(ID) = YSMAXINV*YS2FW(ID)
	    YS4FW(ID) = YSMAXINV*YS4FW(ID)
	  END DO
	  IF (NSW.GT.0) THEN
	    IF ( NSS.GT.0 .OR. ISOLID(0).NE.0 ) THEN
	      DO ID = 0, NSS
	        YS1FW(ID) = YSMAXINV*YS1FW(ID)
	        YS3FW(ID) = YSMAXINV*YS3FW(ID)
	      END DO
	    END IF
	  END IF
	  IF ( (NSW+1).LT.NOL .OR. ISOLID(NOL).NE.0 ) THEN
	    DO ID = NSW, NOL-1
	      YS1FW(ID) = YSMAXINV*YS1FW(ID)
	      YS3FW(ID) = YSMAXINV*YS3FW(ID)
	    END DO
	  END IF
C	  make ys"icmax"fw(idmax) exactly 1
	  IF (ICMAX.EQ.1) THEN
	    YS1FW(IDMAX) = 1
	  ELSE IF (ICMAX.EQ.2) THEN
	    YS2FW(IDMAX) = 1
	  ELSE IF (ICMAX.EQ.3) THEN
	    YS3FW(IDMAX) = 1
	  ELSE IF (ICMAX.EQ.4) THEN
	    YS4FW(IDMAX) = 1
	  ELSE
	    STOP 45167
	  END IF
	ELSE
	  IDMAX = -1
	  ICMAX = 0
	END IF

	WRITE(*,*) '  idmax,zd(idmax),icmax ',IDMAX,SNGL(ZD(IDMAX)),ICMAX

	RETURN
	END
