c-----------------------
c	program MTO
c-----------------------
c ---- reduction de mesures meteo au niveau de la mer pour GGPS (Ashtech)
c ---- P. Briole: 1-6-91 - formules de C. Boucher, 7-2-91
c      modifi‚ par JCR le 25-11-91
c
	real*8 p,ts,th,alt,pmb,phg
	real*8 pvss,pvsh,po,tso,ho
     	character*12 NOM, FICH
c
 	FICH='meteo.ed'
        OPEN(6,file=FICH)
       write(6,*) ' M‚t‚o et r‚duction au niveau de la mer :'
c
       write(6,100) 
 100   format(' No',7x,'Alt',4x,'P(mb)  P(mmHg)',2x,'Ts  Th',4x,
     *' Po    To    Hr %')
 105   format(' J =',I5)
       write(6,*)'----------------------------------------------------'
       write(*,*) '------'
  10   write(*,*) '   No ou nom du point, ou -FIN- : '
        read(*,'(A)') NOM
       if(NOM.eq.'0  ') goto 21
       if(NOM.eq.'0') goto 21
       if(NOM.eq.'HUM') goto 21
       if(NOM.eq.'hum') goto 21
       if(NOM.eq.'FIN') goto 99
       if(NOM.eq.'fin') goto 99
   9   write(*,*) ' No Jour :'
       read(*,*) JOUR
       write(6,105) JOUR 
       write(6,*)'---------'
c
       write(*,*) ' Altitude du point (m) : '
	read(*,*) alt
        SPO=0.
        STO=0.
	SHO=0.  
        NO=0
c
  11   write(*,*) ' Pression : P mb : signe (+), P mm-Hg, signe (-):'
       write(*,*) '               (P = 0 --> moyenne et nouv. site)'
        read(*,*) p
       if (p.EQ.0) goto 12
       if (p.GT.0) goto 20
        phg=dabs(p)
        pmb=phg/0.75005
        goto 21
  20    pmb=p
        phg=pmb*0.75005
c
  21   write(*,*) ' temp seche, temp humide :'
	read(*,*) ts,th
c
	tso=ts+6.5d-3*alt
	po=pmb*((1.d0-2.26d-5*alt)**(-5.225d0))
	pvss=1.d1**(7.857d-1+7.5d0*ts/(ts+273.16d0))
	pvsh=1.d1**(7.857d-1+7.5d0*th/(th+273.16d0))
	ho=1.d2*(pvsh-6.6d-4*p*(1.d0+1.15d-3*th)*(ts-th))/pvss
c
	write(*,*) ' Valeurs ramenees au niveau de la mer '
	write(*,*) ' Pression (mb), temp seche, humidite relative'
	write(*,'(3f10.1)') po,tso,ho
c
        SPO=SPO+po
        STO=STO+tso
        SHO=SHO+ho  
        NO=NO+1
c
       write(6,101) NOM, alt, pmb, phg, ts, th, po, tso, ho
  101  format(1x,A6,F8.2,1x,2(F6.1,1x),2(F4.1,1x),F8.1,1x,F4.1,1x,F6.3)
  102  format(40x,F8.1,1x,F4.1,1x,F6.3)
      goto 11  
   12  PM=SPO/NO
       TM=STO/NO
       HM=SHO/NO
       write(6,*)'                                         ------------'
       write(6,102) PM,TM,HM 
c       write(6,*)'                                         ------------'
c       write(6,*)'----------------------------------------------------'
       write(6,*)' '
      goto 10
   99	end

	 	