!===============================================================
! macro to test that the psiT*K*phi=(2piFreq)^2 and psiT*M*phi=Id 
! input : arg1 = jobname
! ouput : 2 text files containing the dump of PsiTKPhi and PsiTMPhi
!===============================================================

/com, *** Check that the eigenshapes diagonalize K and M ***

jobname   = arg1
fullfile  = '%jobname%.full'
modefile  = '%jobname%.mode'
lmodefile = '%jobname%.lmode'
chk_K     = '%jobname%_chk_K.txt'
chk_M     = '%jobname%_chk_M.txt'

*status,fullfile

! READ K,M AND Nod2Bcs MATRICES FROM THE FULL FILE
*SMAT,MassMatrix ,D,IMPORT,FULL,fullfile,MASS
*SMAT,StiffMatrix,D,IMPORT,FULL,fullfile,STIFF
*SMAT,NodToBcs   ,D,IMPORT,FULL,fullfile,NOD2BCS

! READ THE MODE SHAPES FROM THE MODE FILE AND THE LMODE FILE
*DMAT,Phi,Z,IMPORT,MODE,modefile
*DMAT,Psi,Z,IMPORT,MODE,lmodefile

! CONVERT THEM TO THE BCS ORDERING
*MULT,NodToBcs,,Phi,,BCSPhi
*MULT,NodToBcs,,Psi,,BCSPsi

! CREATE PsiTMPhi = (Psi)T*M*Phi
*MULT,MassMatrix ,,BCSPhi,,MPhi
*MULT,StiffMatrix,,BCSPhi,,KPhi

*MULT,BCSPsi,TRANS,MPhi,,PsiTMPhi
*MULT,BCSPsi,TRANS,KPhi,,PsiTKPhi

! PRINT THIS MATRIX: IT SHOULD BE THE IDENTITY MATRIX [I]
/com, *** Print the matrix PsiT*M*Phi in chk_M.txt***
*PRINT,PsiTMPhi,chk_M

! PRINT THIS MATRIX: IT SHOULD BE THE DIAGONAL MATRIX [lambda]
/com, *** Print the matrix PsiT*K*Phi in chk_K.txt***
*PRINT,PsiTKPhi,chk_K

*return,1
