program make_title implicit none include 'max.inc' include 'formats.inc' c c Purpose to generate the title for the plot that is generated c by the "vizu.bash" script c c Variables integer Nmol,mol integer ios character*(Nchar_mx) spectrum_file character*(Nchar_mx) data_file character*(Nchar_mx) output_file character*(Nchar_mx) title double precision P,T double precision x(1:Nmol_mx) character*(Nchar_mx) mol_name(1:Nmol_mx) integer nap character*(Nchar_mx) P_str character*(Nchar_mx) T_str character*(Nchar_mx) x_str integer err1 character*(Nchar_mx) final_molname c label integer strlen character*(Nchar_mx) label label='program make_title' open(10,file='./status_p1') write(10,*) 1 close(10) c Reading spectrum file data_file='./spectrum_file' open(10,file=data_file(1:strlen(data_file)), & status='old',iostat=ios) if (ios.ne.0) then ! file not found call error(label) write(*,*) 'File could not be found:' write(*,*) data_file(1:strlen(data_file)) stop else read(10,10) spectrum_file endif close(10) c read thermodynamic conditions open(10,file=spectrum_file(1:strlen(spectrum_file)), & status='old',iostat=ios) if (ios.ne.0) then ! file not found call error(label) write(*,*) 'File could not be found:' write(*,*) spectrum_file(1:strlen(spectrum_file)) stop else read(10,*) read(10,*) P read(10,*) read(10,*) T read(10,*) read(10,*) Nmol if (Nmol.gt.Nmol_mx) then call error(label) write(*,*) 'Nmol',Nmol write(*,*) 'while Nmol_mx=',Nmol_mx stop endif read(10,*) do mol=1,Nmol read(10,23) !'Molecule index:',mol read(10,10) !'Name:' read(10,10) mol_name(mol)(1:strlen(mol_name(mol))) read(10,10) !'Concentration:' read(10,50) x(mol) enddo ! mol endif close(10) c generate title title='set title "P=' nap=3 if (P.gt.1.0D-3) then call dble2str_noexp(P,nap,P_str,err1) if (err1.ne.0) then call error(label) write(*,*) 'Could not convert to character string:' write(*,*) 'P=',P stop else title=title(1:strlen(title)) & //P_str(1:strlen(P_str)) & //' atm' & //' ,T=' endif else ! P<1.0D-5 atm call dble2str_noexp(P*1.013D+5,nap,P_str,err1) if (err1.ne.0) then call error(label) write(*,*) 'Could not convert to character string:' write(*,*) 'P=',P stop else title=title(1:strlen(title)) & //P_str(1:strlen(P_str)) & //' Pa' & //' ,T=' endif endif nap=1 call dble2str_noexp(T,nap,T_str,err1) if (err1.ne.0) then call error(label) write(*,*) 'Could not convert to character string:' write(*,*) 'T=',T stop else title=title(1:strlen(title)) & //T_str(1:strlen(T_str)) & //' K' endif do mol=1,Nmol nap=3 call dble2str_noexp(x(mol),nap,x_str,err1) if (err1.ne.0) then call error(label) write(*,*) 'Could not convert to character string:' write(*,*) 'x=',x(mol) stop else call prepare_molname(mol_name(mol),final_molname) c Debug c write(*,*) 'final_molname=', c & final_molname(1:strlen(final_molname)) c stop c Debug title=title(1:strlen(title)) & //' ,x(' & //final_molname(1:strlen(final_molname)) & //')=' & //x_str(1:strlen(x_str)) if (strlen(title).gt.100) then title=title(1:strlen(title)) & //' \n' endif endif enddo ! mol title=title(1:strlen(title)) & //'"' write(*,*) 'Title has been generated:' write(*,*) title(1:strlen(title)) c record title output_file='./plot_title.txt' open(11,file=output_file(1:strlen(output_file))) write(11,10) title(1:strlen(title)) close(11) write(*,*) 'Output file has been generated:' write(*,*) output_file(1:strlen(output_file)) open(10,file='./status_p1') write(10,*) 0 close(10) end subroutine prepare_molname(molname,final_molname) implicit none include 'max.inc' c c Purpose: format the molecule name with indexes c c Input: c + molname: molecule name, as found in the spectrum file c c Output: c + final_molname: molecule name, with integers as indexes c c I/O character*(Nchar_mx) molname character*(Nchar_mx) final_molname c temp integer i,n logical is_int integer int_val character*1 char c label integer strlen character*(Nchar_mx) label label='subroutine prepare_molname' n=strlen(molname) final_molname='' do i=1,n char=molname(i:i) call char_is_int(char,is_int,int_val) if (is_int) then final_molname=final_molname(1:strlen(final_molname)) & //'_{' & //char(1:1) & //'}' else final_molname=final_molname(1:strlen(final_molname)) & //char(1:1) endif enddo ! i return end subroutine char_is_int(char,is_int,int_val) implicit none include 'max.inc' c c Purpose: determine whether or not a given character is an integer c c Input: c + char: single character c c Output: c + is_int: true if "char" is an integer c + int_val: value of the integer if is_int=true c c I/O character*1 char logical is_int integer int_val c temp integer i character*1 i_str c label integer strlen character*(Nchar_mx) label label='subroutine char_is_int' is_int=.false. do i=0,9 write(i_str,'(I1)') i if (char(1:1).eq.i_str) then is_int=.true. int_val=i endif enddo ! i return end