! This module contains routines to write null results when ! SP_ace cannot converge to a meaningful result. ! ! It is part of the program SP_Ace, which derives stellar parameters, ! such as gravity, temperature, and element abundances from optical ! stellar spectra, assuming Local Thermodynamic Equilibrium (LTE) ! and 1D stellar atmosphere models. ! ! Copyright (C) 2016 Corrado Boeche ! ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see . MODULE error USE num_type USE share, ONLY: obs_sp_file IMPLICIT NONE CONTAINS !######################### SUBROUTINE error_msg(conv,text) USE space_pars, ONLY: null_val USE share, ONLY: ele2write USE data_lib, ONLY: ELE_symb IMPLICIT NONE INTEGER(I1B), INTENT(IN) :: conv INTEGER(I1B) :: i CHARACTER(LEN=*) :: text CHARACTER(LEN=5) :: null CHARACTER(LEN=6) :: TGMc,lo_TGMc,up_TGMc CHARACTER(LEN=5) :: ABDc,lo_ABDc,up_ABDc CHARACTER(LEN=1500) :: values_TGM, values_ABD, values_lab CHARACTER(LEN=1500) :: line, header write(*,*) text, ' SP_Ace exit with no results!' OPEN(unit=10,file='space_msg.txt',action='WRITE') WRITE(unit=10,fmt=*) '### ', obs_sp_file WRITE(unit=10,fmt=*) ' ', text, ', SP_Ace exit with no results!' CLOSE(unit=10) !give the null value of the user IF(null_val.EQ.'NaN') THEN null=' NaN' ELSE IF(null_val.EQ.'null') THEN null=' null' ELSE IF (null_val.EQ.'-9.99') THEN null='-9.99' END IF TGMc=null lo_TGMc=null up_TGMc=null ABDc=null lo_ABDc=null up_ABDc=null write(line,fmt=*) '' write(header,fmt=*) '' !add convergence header=TRIM(header) // 'conv' write(values_ABD,fmt='(TR3,I2)') conv line=TRIM(line) // TRIM(values_ABD) !add radial velocity header=TRIM(header) // ' RV' write(values_ABD,fmt='(TR3,A5)') TGMc line=TRIM(line) // TRIM(values_ABD) !add fwhm header=TRIM(header) // ' FWHM' write(values_ABD,fmt='(TR3,A5)') TGMc line=TRIM(line) // TRIM(values_ABD) !add S/N header=TRIM(header) // ' S/N' write(values_ABD,fmt='(TR3,A5)') null line=TRIM(line) // TRIM(values_ABD) !add chisq header=TRIM(header) // ' chisq' write(values_ABD,fmt='(TR4,A5)') null line=TRIM(line) // TRIM(values_ABD) header=TRIM(header) // ' Teff ' // ' inf ' // ' sup' write(values_TGM,fmt='(TR1,A5,TR1,A5,TR1,A5)') TGMc,lo_TGMc,up_TGMc line=TRIM(line) // TRIM(values_TGM) header=TRIM(header) // ' logg' // ' inf' // ' sup' write(values_TGM,fmt='(TR2,A5,TR1,A5,TR1,A5)') TGMc,lo_TGMc,up_TGMc line=TRIM(line) // TRIM(values_TGM) header=TRIM(header) // ' [M/H]' // ' inf' // ' sup' write(values_TGM,fmt='(TR2,A5,TR1,A5,TR1,A5)') TGMc,lo_TGMc,up_TGMc line=TRIM(line) // TRIM(values_TGM) !now write the elements DO i=1,INT(SIZE(ele2write,1),I1B) !define the position of the element ele2write(i) in the array ele2meas, if any write(values_lab,fmt='(TR3,A6,TR1,A16)') ELE_symb(INT(ele2write(i))), ' inf sup Nlin' header=TRIM(header) // TRIM(values_lab) write(values_ABD,fmt='(TR4,A5,TR1,A5,TR1,A5,TR1,I4)') ABDc,lo_ABDc,up_ABDc,0 line=TRIM(line) // TRIM(values_ABD) END DO OPEN(unit=10,file='space_TGM_ABD.dat',action='WRITE')!,position='APPEND') write(10,fmt=*) TRIM(header) write(10,fmt=*) TRIM(line) CLOSE(10) STOP 1 END SUBROUTINE error_msg !######################### SUBROUTINE stop_msg(text) CHARACTER(LEN=*) :: text write(*,*) text, ', SP_Ace stops!' OPEN(unit=10,file='space_msg.txt',action='WRITE') WRITE(unit=10,fmt=*) '### ', obs_sp_file WRITE(unit=10,fmt=*) ' ', text, ', SP_Ace stops!' CLOSE(unit=10) STOP 1 END SUBROUTINE stop_msg !######################### END MODULE error