program readtrajall ******************************************************************************** * * * This is a programm to read in the FLEXPART output * * * ******************************************************************************** * * * Variables: * * * * Constants: * * * ******************************************************************************** use par_mod use com_mod integer itime, i, j, help, intervali, anz, anzi, eintrag integer ausgabe, schichten, schichtanz, sink, level(maxpart) real xlon(maxpart), ylat(maxpart), topo, interval real pvi, qvi, rhoi, hmixi, tri, tti, dicke, hoehe real maxheight(maxpart), schichtx logical valid(maxpart) real, dimension(:,:), allocatable :: zposit, anzahl real, dimension(:,:,:), allocatable :: gesamtmass, mass real, dimension(:,:), allocatable :: obermasse, sinkcount real, dimension(:), allocatable :: anzahl2 real*8 stzeitstart, stzeitend, stzeittemp real*8 zeitstart, zeitend, zeittemp CHARACTER (LEN=*), PARAMETER :: + pfad='/work/afiehn/flexpart/output/test/' !CHARACTER (LEN=*), PARAMETER :: !+pfad='/home/stegtmeier/flexpart/output/sonne-1/release-a1/' CHARACTER (LEN=60) :: name, startdate, enddate, datetemp CHARACTER (LEN=60) :: schichtxstr CHARACTER (LEN=150) :: filename ! npoint(i) release point of each particle ! xlon longitude ! ylat latitude ! ztra1(i) height in m ! itramem(i) memorized release times of the particles ! topo land height in m ! pvi potential vorticity ! qvi H2O ! hmixi 'PBL' height in m ! tri tropopause height in m ! tti temperature ! xmass1(i,j) mass of the species j startdate = '20110622040000' ! Begin des Zeitraumes in yyyymmddhhmmss enddate = '20110628220000' ! Ende des Zeitraumes in ------- ! startdate = '20021103150000' ! Begin des Zeitraumes in yyyymmddhhmmss ! enddate = '20021203150000' ! Ende des Zeitraumes in ------- interval = 6.0 ! Länge des Intervals [h] intervali = int(interval) ausgabe = 1 ! für 1 Ausgabe von lon, lat, height, mass in eine ! Datei pro Zeitpunkt, für 0 keine Ausgabe, schichten = 0 ! für 1 wird Gesamtmasse in jeder Schicht ! bestimmt, für 0 keine Gesamtmasse, schichtanz = 40 ! Anzahl der Schichten zwischen 0 und 20 km ! Zahl muss per Hand in Dateiausgabe (Formatstring) ! der Gesamtmasse eingetragen werden sink = 0 ! für 1 wird maximale Höhe und späteres Absinken der ! Trajektorien bestimmt, für sink=1 muß auch ! schichten=1 gesetzt sein eintrag = 0 ! für 1 wird eingetragene Masse oberhalb der Schicht ! x bestimmt (Summe aller Traj.massen über alle Zeitpkt. schichtx = 17.0 ! Höhe der Schicht x [km] ! Berechnung der Anzahl der Zeitpunkte read(startdate,fmt='(i8,f2.0)') help,zeitstart read(enddate,fmt='(i8,f2.0)') help,zeitend call standardzeit(startdate(3:8), zeitstart, stzeitstart) call standardzeit(enddate(3:8), zeitend, stzeitend) anz = (stzeitend - stzeitstart) / interval + 1.0 print*, stzeitstart, stzeitend, anz print*, anz, maxpart allocate(zposit(anz,maxpart)) allocate(mass(anz,maxpart,maxspec)) allocate(gesamtmass(anz,schichtanz,maxspec)) allocate(anzahl(anz,schichtanz)) allocate(sinkcount(anz,schichtanz)) allocate(obermasse(anz,maxspec)) allocate(anzahl2(anz)) obermasse = 0 gesamtmass = 0 anzahl = 0 anzahl2 = 0 sinkcount = 0 maxheight = 0 valid = .true. ! Anzahl der Species nspec = 2 ! Einlesen für alle Zeitpunkte (anzi = 1,anz) do 70 anzi = 1,anz stzeittemp = stzeitstart + (anzi-1)*interval call normalzeit(stzeittemp,datetemp(3:8),zeittemp) write(datetemp(9:11),fmt='(f3.0)') zeittemp if (zeittemp == 0.00000000000) then datetemp(9:10) = '00' else if (zeittemp < 10.0000000000) then datetemp(9:9) = '0' end if datetemp(11:14) = '1000' ! mmss manuell ergänzt filename = pfad//'partposit_'//startdate(1:2)//datetemp(3:14) write(*,*) 'filename ', filename open(10,file=filename,form='unformatted',status='old') read(10) itime read(10) numpart !write(*,*) 'numpart: ', numpart ! Einlesen aller Trajektorienpunkte zu einem bestimmten Zeitpunkt do 71 i=1,numpart read(10) npoint(i), xlon(i), ylat(i), ztra1(i), + itramem(i),topo,pvi,qvi,rhoi,hmixi,tri,tti, + (xmass1(i,j),j=1,nspec) zposit(anzi,i) = ztra1(i) do 72 j=1,nspec mass(anzi,i,j) = xmass1(i,j) 72 continue !write(*,*) hmixi,tri,tti,xmass1(i,1),xmass1(i,2),nspec 71 continue close(10) ! Ausgabe von lon, lat, height, mass aller Trajektorienpunkte ! zu einem festen Zeitpunkt (Ausgabe für Matlab) if (ausgabe == 1) then filename = pfad//'zposit_'//startdate(1:2)//datetemp(3:14) write(*,*) 'filename ', filename open(11,file=filename,form='formatted',status='replace') do 73 i=1,numpart write(11,fmt='(f10.5,a,f9.5,a,f7.1,a,e14.7,a,e14.7)') + xlon(i),' ',ylat(i),' ',zposit(anzi,i),' ', + mass(anzi,i,1),' ',mass(anzi,i,2) 73 continue close(11) endif ! Bestimmt Gesamtmasse in jeder Schicht (Schichtanz gibt die Anzahl der ! Schichten zwischen 0 und 20 km) if (schichten == 1) then dicke = 20./schichtanz do 74 i=1,numpart do 75 j=1,schichtanz if (zposit(anzi,i) < j*dicke*1000.) then gesamtmass(anzi,j,:) = + gesamtmass(anzi,j,:) + mass(anzi,i,:) level(i) = j anzahl(anzi,j) = anzahl(anzi,j) + 1 goto 76 endif 75 continue 76 schichten = 1 74 continue endif ! Bestimmen der maximalen Höhe einer jeden Trajektorie im Vergleich mit anderen ! Zeitpunkten, Zähler für Absinken der Trajektorien if (sink == 1) then do 77 i=1,numpart if (maxheight(i) < zposit(anzi,i)) then maxheight(i) = zposit(anzi,i) endif if (maxheight(i) > zposit(anzi,i) + 200) then sinkcount(anzi,level(i)) = sinkcount(anzi,level(i))+1 maxheight(i) = zposit(anzi,i) endif 77 continue endif ! Die zu jedem Zeitpunkt eingetragene Masse oberhalb der Schicht x wird bestimmt, ! Trajektorien die bereits Masse eingetragen haben, werden auf false gesetzt ! neu eingefügt: nur die Masse eingetragen in den Tropen wird bestimmt if (eintrag == 1) then do 78 i=1,numpart if (valid(i)) then if (schichtx*1000. < zposit(anzi,i)) then if ((ylat(i) > -30.) .and. (ylat(i) < 30)) then obermasse(anzi,:)=obermasse(anzi,:)+mass(anzi,i,:) anzahl2(anzi) = anzahl2(anzi) + 1 valid(i) = .false. endif endif endif 78 continue endif 70 CONTINUE ! Ausgabe von Gesamtmasse in jeder Schicht und zu jedem ! Zeitpunkt für Matlab-weiterverarbeitung if (schichten == 1) then filename = pfad//'gesamtmasse1' write(*,*) 'filename ', filename open(12,file=filename,form='formatted',status='replace') do 80 anzi = 1,anz write(12,fmt='(40(e14.7))') gesamtmass(anzi,:,1) 80 continue close(12) endif ! Ausgabe von Gesamtmasse in jeder Schicht und zu jedem ! Zeitpunkt für Matlab-weiterverarbeitung if (schichten == 1) then filename = pfad//'gesamtmasse2' write(*,*) 'filename ', filename open(12,file=filename,form='formatted',status='replace') do 86 anzi = 1,anz write(12,fmt='(40(e14.7))') gesamtmass(anzi,:,2) 86 continue close(12) endif ! Ausgabe von Gesamtanzahl aller Trajektorien in jeder Schicht und zu jedem ! Zeitpunkt für Matlab-weiterverarbeitung if (schichten == 1) then filename = pfad//'gesamtanzahl' write(*,*) 'filename ', filename open(17,file=filename,form='formatted',status='replace') do 81 anzi = 1,anz write(17,fmt='(40(f8.1))') anzahl(anzi,:) 81 continue close(17) endif ! Ausgabe der dazugehörigen Dimensionsvektoren (Schichten ! und Zeitpunkte) für Matlab-weiterverarbeitung if ((schichten == 1).or.(sink == 1).or.(eintrag == 1)) then filename = pfad//'gesamt_dim1' write(*,*) 'filename ', filename open(13,file=filename,form='formatted',status='replace') do 82 anzi = 1,anz stzeittemp = stzeitstart + (anzi-1)*interval call normalzeit(stzeittemp,datetemp(3:8),zeittemp) write(datetemp(9:11),fmt='(f3.0)') zeittemp if (zeittemp == 0.00000000000) then datetemp(9:10) = '00' else if (zeittemp < 10.0000000000) then datetemp(9:9) = '0' end if write(13,fmt='(5(a))') startdate(1:2), datetemp(3:8), + 'T', datetemp(9:10), '0000' 82 continue close(13) filename = pfad//'gesamt_dim2' write(*,*) 'filename ', filename open(14,file=filename,form='formatted',status='replace') do 83 j = 1,schichtanz hoehe = j*dicke*1000. write(14,fmt='(f7.1)') hoehe 83 continue close(14) endif ! Ausgabe von Zähler des Absinkens in jeder Schicht und zu jedem ! Zeitpunkt für Matlab-weiterverarbeitung if (sink == 1) then filename = pfad//'sinkcount' write(*,*) 'filename ', filename open(15,file=filename,form='formatted',status='replace') do 84 anzi = 1,anz write(15,fmt='(40(e14.7))') sinkcount(anzi,:)/numpart 84 continue close(15) endif ! Ausgabe von eingetragener Masse oberhalb einer Schicht zu jedem ! Zeitpunkt für Matlab-weiterverarbeitung ! neu eingefügt: nur Masse eingetragen in den Tropen wird mitgezählt if (eintrag == 1) then write(schichtxstr,fmt='(f4.1)') schichtx write(*,*) 'schichtxstr ', schichtxstr !filename = pfad(1:lnblnk(pfad))//'eintragtropabove'// filename = pfad(1:lnblnk(pfad))//'eintragtrop2specabove'// +schichtxstr(1:2)//'km' write(*,*) 'filename ', filename open(16,file=filename,form='formatted',status='replace') do 85 anzi = 1,anz write(16,fmt='(40(e14.7))') obermasse(anzi,1) 85 continue do 63 anzi = 1,anz write(16,fmt='(40(e14.7))') obermasse(anzi,2) 63 continue close(16) endif deallocate(zposit) deallocate(mass) deallocate(gesamtmass) deallocate(anzahl) deallocate(sinkcount) deallocate(obermasse) deallocate(anzahl2) end !********************************************************************** subroutine standardzeit(datum, zeit, stzeit) !************************************************* ! eingabewerte : ! datum :character*6 ! z.b.: 920215 ! zeit :real ! z.b.: 10.50 fuer 'halb elf' ! ausgabewert : ! stzeit :real !************************************************* ! stzeit ist eine standardisierte zeitangabe. ! sie gibt stunden seit 1.1.1950, 0.00 uhr an. !************************************************* character*6 datum real*8 zeit real*8 stzeit integer bezugsjahr integer jahr,monat,tag integer jahri,monati integer taganz(12) parameter (bezugsjahr = 50) ! anzahl der tage eines monats: taganz(1) = 31 taganz(3) = 31 taganz(4) = 30 taganz(5) = 31 taganz(6) = 30 taganz(7) = 31 taganz(8) = 31 taganz(9) = 30 taganz(10) = 31 taganz(11) = 30 taganz(12) = 31 read(datum,fmt='(i2,i2,i2)') jahr,monat,tag if (jahr.lt.50) jahr=jahr+100 ! anzahl der februartage: if ((int(real(jahr)/4.)).eq.(real(jahr)/4.)) then ! schaltjahr: taganz(2) = 29 else ! sonst: taganz(2) = 28 end if ! nun werden nacheinander die stunden der jeweils vollstaendigen ! jahre, monate, tage aufaddiert: ! jahre: stzeit = 0 do 10,jahri=bezugsjahr,(jahr-1) if ((int(real(jahri)/4.)).eq.(real(jahri)/4.)) then stzeit = stzeit + 366. * 24. else stzeit = stzeit + 365. * 24. end if 10 continue ! monate: do 20,monati=1,(monat-1) stzeit = stzeit + taganz(monati) * 24. 20 continue ! tage: stzeit = stzeit + (tag - 1) * 24. ! zum schluss kommen noch die stunden an dem letzten, ! unvollstaendigen tag dazu: stzeit = stzeit + zeit end !********************************************************************** subroutine normalzeit(stzeit,datum,zeit) !********************************************************************** ! eingabewert : * ! stzeit :real * ! ausgabewerte : * ! datum :character*6 * ! z.b.: 920215 * ! zeit :real * ! z.b.: 10.50 fuer 'halb elf' * !********************************************************************** ! die routine wandelt stzeit in eine normale datums- und zeitan- * ! gabe zurueck. * ! stzeit ist eine standardisierte zeitangabe. sie gibt stunden * ! seit 1.1.1950, 0.00 uhr an. * !********************************************************************** real*8 stzeit real*8 zeit character*6 datum integer bezugsjahr,jahr,monat,tag,testtage integer taganz(12) ! achtung: muss mit bezugsjahr in routine standardzeit ueberein- ! stimmen! : parameter (bezugsjahr = 50) ! anzahl der tage eines monats: taganz(1) = 31 taganz(3) = 31 taganz(4) = 30 taganz(5) = 31 taganz(6) = 30 taganz(7) = 31 taganz(8) = 31 taganz(9) = 30 taganz(10) = 31 taganz(11) = 30 taganz(12) = 31 ! anzahl der vollstaendigen tage: tag=int(stzeit/24.) ! uebrigbleibende uhrzeit am letzten tag: zeit=stzeit-real(tag)*24. ! vom anfang des bezugsjahres ausgehend, werden die vollstaendigen ! tage verteilt: jahr=bezugsjahr-1 monat=0 10 continue jahr=jahr+1 if (real((int(real(jahr)/4.))).eq.(real(jahr)/4.)) then testtage = 366 taganz(2) = 29 else testtage = 365 taganz(2) = 28 end if if ((tag-testtage).ge.0) then tag=tag-testtage goto 10 else 20 continue monat=monat+1 if ((tag-taganz(monat)).ge.0) then tag=tag-taganz(monat) goto 20 else write(datum,fmt='(i2.2,i2.2,i2.2)')mod(jahr,100),monat,(tag+1) end if end if end