C
C Program DMGM to compute product GM2=DM1*GM1 of diagonal matrix DM1 C and general matrix GM1. C C Version: 5.50 C Date: 2000, October 20 C C Coded by Petr Bulant C Department of Geophysics, Charles University Prague, C Ke Karlovu 3, 121 16 Praha 2, Czech Republic, C E-mail: bulant@seis.karlov.mff.cuni.cz C C....................................................................... C C Description of data files: C C Input data read from the standard input device (*): C The data are read by the list directed input (free format) and C consist of a single string 'SEP': C 'SEP'...String in apostrophes containing the name of the input C SEP parameter or history file with the input data. C No default, 'SEP' must be specified and cannot be blank. C C C Input data file 'SEP': C File 'SEP' has the form of the SEP C parameter file. The parameters, which do not differ from their C defaults, need not be specified in file 'SEP'. C Data specifying dimensions of the matrices: C M1='string'... Name of the file containing a single integer number C specifying the number of rows and columns of matrix DM1 C and rows of matrices GM1 and GM2. C Default: M1=' ' means that the number is 1. C M2='string'... Name of the file containing a single integer number C specifying the number of columns of matrices GM1 and GM2. C Default: M2=' ' means that the number is 1. C Filenames of the files with the matrices: C DM1='string' ... Name of the file containing matrix DM1 (input). C No default, 'DM1' must be specified and cannot be blank. C GM1='string' ... Name of the file containing matrix GM1 (input). C No default, 'GM1' must be specified and cannot be blank. C GM2='string' ... Name of the file containing matrix GM2 (output). C No default, 'GM2' must be specified and cannot be blank. C For general description of the files with matrices refer to file C forms.htm. C Form of the files with matrices: C FORMM='string' ... Form of the files with matrices. Allowed values C are FORMM='formatted' and FORMM='unformatted'. If the form C differs for input and for output files, FORMMR and FORMMW C should be used instead of FORMM. C Default: FORMM='formatted' C FORMMR='string' ... Form of the files with matrices to be read. C Default: FORMMR=FORMM C FORMMW='string' ... Form of the files with matrices to be written. C Default: FORMMW=FORMM C C----------------------------------------------------------------------- C Subroutines and external functions required: EXTERNAL ERROR,RSEP1,RSEP3T,RMAT,WMAT C ERROR ... File error.for. C RSEP1,RSEP3T ... File sep.for. C RMAT,WMAT ... File forms.for. C C Common block /RAMC/: INCLUDE 'ram.inc' C ram.inc C CHARACTER*80 FILSEP,FILE1,FILE2,FILE3 INTEGER M1,M2,M1M2,LU1 PARAMETER (LU1=1) C----------------------------------------------------------------------- C C Reading in a name of the file with the input data: WRITE(*,'(A)') '+DMGM: Enter input filename: ' FILSEP=' ' READ(*,*) FILSEP C C Reading all the data from the SEP file into the memory: IF (FILSEP.NE.' ') THEN CALL RSEP1(LU1,FILSEP) ELSE C DMGM-01 CALL ERROR('DMGM-01: SEP file not given') ENDIF C C Reading the dimensions of the matrices: CALL RSEP3T('M1',FILE1,' ') IF (FILE1.EQ.' ') THEN M1=1 ELSE OPEN(LU1,FILE=FILE1,STATUS='OLD') READ(LU1,*) M1 CLOSE(LU1) ENDIF CALL RSEP3T('M2',FILE1,' ') IF (FILE1.EQ.' ') THEN M2=1 ELSE OPEN(LU1,FILE=FILE1,STATUS='OLD') READ(LU1,*) M2 CLOSE(LU1) ENDIF M1M2=M1*M2 C IF (M1+M1M2.GT.MRAM) THEN C DMGM-02 CALL ERROR('DMGM-02: Small dimension MRAM of array RAM') END IF C C Reading in the names of the files with the matrices: CALL RSEP3T('DM1',FILE1,' ') IF (FILE1.EQ.' ') THEN C DMGM-03 CALL ERROR('DMGM-03: Input file with matrix DM1 not given.') ENDIF CALL RSEP3T('GM1',FILE2,' ') IF (FILE2.EQ.' ') THEN C DMGM-04 CALL ERROR('DMGM-04: Input file with matrix GM1 not given.') ENDIF CALL RSEP3T('GM2',FILE3,' ') IF (FILE3.EQ.' ') THEN C DMGM-05 CALL ERROR('DMGM-05: Output file with matrix GM2 not given.') ENDIF C C Reading input matrices: CALL RMAT(LU1,FILE1,M1,1,RAM) CALL RMAT(LU1,FILE2,M1,M2,RAM(M1+1)) C WRITE(*,'(A)') '+DMGM: Working... ' C C Multiplication: DO 12 I1=1,M1 AUX=RAM(I1) DO 11 I2=M1+I1,M1+M1*M2,M1 RAM(I2)=AUX*RAM(I2) 11 CONTINUE 12 CONTINUE C C Writing output matrix: IF (FILE3.NE.' ') THEN CALL WMAT(LU1,FILE3,M1,M2,RAM(M1+1)) ENDIF WRITE(*,'(A)') '+DMGM: Done. ' C STOP END C C======================================================================= C INCLUDE 'error.for' C error.for INCLUDE 'sep.for' C sep.for INCLUDE 'forms.for' C forms.for INCLUDE 'length.for' C length.for C C======================================================================= C