c kspectrum (http://www.meso-star.com/en_Products.html) - This file is part of kspectrum c Copyright (C) 2008-2015 - Méso-Star - Vincent Eymet c c This file must be used under the terms of the CeCILL license. c This source file is licensed as described in the file COPYING, which c you should have received as part of this distribution. The terms c are also available at c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt c subroutine identify_molecules(string,nmolec,molec_name) implicit none include 'max.inc' include 'formats.inc' integer strlen,c1,c2,n,nmolec,cstart,cend integer mol,m,mmf character*(Nchar_mx) string character*10 molec_name(1:Nmol_max),cmol,imol character*1 char1,char2 c Identify the number of molecules in the provided "string', as well as their names (in lowervase) nmolec=0 n=strlen(string) do c1=1,n-2 char1=string(c1:c1+1) if (char1.eq.'[') then cstart=c1+1 do c2=c1+1,n char2=string(c2:c2+1) if (char2.eq.']') then cend=c2-1 goto 123 endif enddo 123 continue c nc=cend-cstart+1 nmolec=nmolec+1 molec_name(nmolec)=string(cstart:cend) endif enddo c Look for multiple definitions do mol=1,nmolec cmol=molec_name(mol) mmf=0 if (mol.gt.1) then do m=1,mol-1 imol=molec_name(m) if (imol(1:strlen(imol)).eq.cmol(1:strlen(cmol))) then mmf=1 endif enddo ! m endif if (mol.lt.nmolec) then do m=mol+1,nmolec imol=molec_name(m) if (imol(1:strlen(imol)).eq.cmol(1:strlen(cmol))) then mmf=1 endif enddo ! m endif if (mmf.eq.1) then write(*,*) 'Error from routine identify_molecules:' write(*,*) 'While reading composition file,' write(*,*) 'molecule:',cmol(1:strlen(cmol)) write(*,*) 'was found more than once' stop endif enddo return end