Changeset d7935de in flexpart.git
- Timestamp:
- Sep 11, 2018, 6:06:31 PM (6 years ago)
- Branches:
- univie
- Children:
- 93786a1
- Parents:
- 34f1452
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
options/RELEASES
r5b7ec80 rd7935de 1 1 &RELEASES_CTRL 2 2 NSPEC= 1, 3 SPECNUM_REL= 24,3 NUMSPEC_REL= 24, 4 4 / 5 5 &RELEASE … … 8 8 IDATE2= 20170102, 9 9 ITIME2= 090000, 10 LON1= 0.000 ,11 LON2= 0.000 ,12 LAT1= 0.000 ,13 LAT2= 0.000 ,10 RLON1= 0.000 , 11 RLON2= 0.000 , 12 RLAT1= 0.000 , 13 RLAT2= 0.000 , 14 14 Z1= 50.000 , 15 15 Z2= 50.000 , 16 ZKIND= 1,17 MASS= 1.0000E8 ,18 PARTS= 1000016 IKINDZ= 1, 17 RMASS= 1.0000E8 , 18 NPARTS= 10000 19 19 COMMENT="TEST1", 20 20 / -
src/advance.f90
r5184a7c rd7935de 421 421 !************************************************************* 422 422 !************** CBL options added by mc see routine cblf90 *** 423 if ( cblflag.eq.1) then !modified by mc423 if (iflagcbl.eq.1) then !modified by mc 424 424 if (-h/ol.gt.5) then !modified by mc 425 425 !if (ol.lt.0.) then !modified by mc … … 515 515 516 516 end do 517 if ( cblflag.ne.1) nrand=nrand+i517 if (iflagcbl.ne.1) nrand=nrand+i 518 518 519 519 ! Determine time step for next integration -
src/com_mod.f90
r1a8fbee rd7935de 26 26 integer :: length(numpath+2*maxnests) 27 27 character(len=256) :: pathfile, flexversion, flexversion_major, arg1, arg2 28 character(len=256) :: ohfields_path28 character(len=256) :: path_ohfields 29 29 30 30 ! path path names needed for trajectory model … … 34 34 ! flexversion_major version of flexpart (major version number) 35 35 ! arg input arguments from launch at command line 36 ! ohfields_pathpath to binary files for OH fields36 ! path_ohfields path to binary files for OH fields 37 37 38 38 !******************************************************** … … 73 73 integer :: ind_rel,ind_samp,ioutputforeachrelease,linit_cond,surf_only 74 74 logical :: turbswitch 75 integer :: cblflag!added by mc for cbl75 integer :: iflagcbl !added by mc for cbl 76 76 77 77 ! ctl factor, by which time step must be smaller than Lagrangian time scale … … 104 104 105 105 ! ind_rel and ind_samp are used within the code to change between mass and mass-mix (see readcommand.f) 106 ! cblflag!: 1 activate cbl skewed pdf routines with bi-gaussina pdf whan OL<0 added by mc106 ! iflagcbl !: 1 activate cbl skewed pdf routines with bi-gaussina pdf whan OL<0 added by mc 107 107 108 108 -
src/initialize.f90
rdb712a8 rd7935de 158 158 if (.not.turbswitch) then ! modified by mc 159 159 wp=wp*sigw 160 else if ( cblflag.eq.1) then ! modified by mc160 else if (iflagcbl.eq.1) then ! modified by mc 161 161 if(-h/ol.gt.5) then 162 162 !if (ol.lt.0.) then -
src/readOHfield.f90
r3f149cc rd7935de 60 60 61 61 62 open(unitOH,file=trim( ohfields_path) &62 open(unitOH,file=trim(path_ohfields) & 63 63 //'OH_FIELDS/OH_variables.bin',status='old', & 64 64 form='UNFORMATTED', iostat=ierr, convert='little_endian') 65 65 66 66 if(ierr.ne.0) then 67 write(*,*) 'Cannot read binary OH fields in ',trim( ohfields_path)//'OH_FIELDS/OH_variables.bin'67 write(*,*) 'Cannot read binary OH fields in ',trim(path_ohfields)//'OH_FIELDS/OH_variables.bin' 68 68 stop 69 69 endif -
src/readageclasses.f90
r5f9d14a rd7935de 29 29 ! Author: A. Stohl * 30 30 ! 20 March 2000 * 31 ! 31 32 ! HSO, 1 July 2014 * 32 33 ! Added optional namelist input * 34 ! * 35 ! PS, 6/2015-9/2018 some variable names changed as in readreleases.f90 * 36 ! catch nageclass>maxage properly * 33 37 ! * 34 38 !***************************************************************************** … … 47 51 integer :: i 48 52 49 ! namelist helpvariables50 integer :: readerror53 ! namelist aux variables 54 integer :: ios 51 55 52 56 ! namelist declaration 53 namelist / ageclass/ &57 namelist /nml_ageclass/ & 54 58 nageclass, & 55 59 lage … … 71 75 !************************************************ 72 76 73 open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES',form='formatted',status='old',err=999) 77 open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES', & 78 form='formatted',status='old',err=999) 74 79 75 80 ! try to read in as a namelist 76 read(unitageclasses, ageclass,iostat=readerror)81 read(unitageclasses, nml_ageclass, iostat=ios) 77 82 close(unitageclasses) 78 83 79 if ((nageclass.lt.0).or.(readerror.ne.0)) then 80 open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES',status='old',err=999) 81 do i=1,13 82 read(unitageclasses,*) 83 end do 84 read(unitageclasses,*) nageclass 85 read(unitageclasses,*) lage(1) 86 do i=2,nageclass 87 read(unitageclasses,*) lage(i) 84 if (ios .ne. 0) then ! failed to read nml, assume simple text 85 open(unitageclasses,file=path(1)(1:length(1))// & 86 'AGECLASSES',status='old',err=999) 87 call skplin(13,unitageclasses) 88 read(unitageclasses,*) nageclass ! number of classes 89 if (nageclass.gt.maxageclass) goto 1001 90 do i=1,nageclass 91 read(unitageclasses,*) lage(i) ! max age per classes 88 92 end do 89 93 close(unitageclasses) 90 94 endif 91 95 96 if (nageclass.lt.1) goto 1002 97 92 98 ! write ageclasses file in namelist format to output directory if requested 93 99 if (nmlout.and.lroot) then 94 open(unitageclasses,file=path(2)(1:length(2))//'AGECLASSES.namelist',err=1000) 95 write(unitageclasses,nml=ageclass) 100 open(unitageclasses,file=path(2)(1:length(2))//'AGECLASSES.namelist', & 101 err=1000) 102 write(unitageclasses,nml=nml_ageclass) 96 103 close(unitageclasses) 97 endif98 99 if (nageclass.gt.maxageclass) then100 write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE #### '101 write(*,*) ' #### CLASSES GREATER THAN MAXIMUM ALLOWED. #### '102 write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES OR #### '103 write(*,*) ' #### RECOMPILE WITH LARGER MAXAGECLASS IN #### '104 write(*,*) ' #### FILE PAR_MOD. #### '105 stop106 104 endif 107 105 … … 126 124 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "AGECLASSES" #### ' 127 125 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 128 write(*,'(a)') path(1)(1:length(1))126 write(*,'(a)') trim(path(1)) 129 127 stop 130 128 … … 134 132 stop 135 133 134 1001 continue 135 write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE #### ' 136 write(*,*) ' #### CLASSES GREATER THAN MAXIMUM ALLOWED. #### ' 137 write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES OR #### ' 138 write(*,*) ' #### RECOMPILE WITH LARGER MAXAGECLASS IN #### ' 139 write(*,*) ' #### FILE PAR_MOD. #### ' 140 stop 141 142 1002 continue 143 write(*,*) ' #### FLEXPART MODEL ERROR! NUMBER OF AGE #### ' 144 write(*,*) ' #### CLASSES < 1 #### ' 145 write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES #### ' 146 stop 136 147 137 148 end subroutine readageclasses -
src/readcommand.f90
r77778f8 rd7935de 33 33 ! Unknown, unknown: various * 34 34 ! Petra Seibert, 2018-06-08: improve error msgs * 35 ! PS 6/2015: Minor changes in variable names and layout * 35 36 ! * 36 37 !***************************************************************************** … … 84 85 character(len=50) :: line 85 86 logical :: old 86 integer :: readerror87 88 namelist / command/ &89 ldirect, &90 ibdate,ibtime, &91 iedate,ietime, &92 loutstep, &93 loutaver, &94 loutsample, &95 itsplit, &96 lsynctime, &97 ctl, &98 ifine, &99 iout, &100 ipout, &101 lsubgrid, &102 lconvection, &103 lagespectra, &104 ipin, &105 ioutputforeachrelease, &106 iflux, &107 mdomainfill, &108 ind_source, &109 ind_receptor, &110 mquasilag, &111 nested_output, &112 linit_cond, &113 lnetcdfout, &114 surf_only, &115 cblflag, &116 ohfields_path117 118 ! Presetting namelist command 119 ldirect=0120 ibdate=20000101121 ibtime=0122 iedate=20000102123 ietime=0124 loutstep=10800125 loutaver=10800126 loutsample=900127 itsplit=999999999128 lsynctime=900129 ctl=-5.0130 ifine=4131 iout=3132 ipout=0133 lsubgrid=1134 lconvection=1135 lagespectra=0136 ipin=1137 ioutputforeachrelease=1138 iflux=1139 mdomainfill=0140 ind_source=1141 ind_receptor=1142 mquasilag=0143 nested_output=0144 linit_cond=0145 lnetcdfout=0146 surf_only=0147 cblflag=0 ! if using old-style COMMAND file, set to 1 here to use mc cbl routine148 ohfields_path="../../flexin/"87 integer :: ios, icmdstat 88 89 namelist /nml_command/ & 90 ldirect, & 91 ibdate,ibtime, & 92 iedate,ietime, & 93 loutstep, & 94 loutaver, & 95 loutsample, & 96 itsplit, & 97 lsynctime, & 98 ctl, & 99 ifine, & 100 iout, & 101 ipout, & 102 lsubgrid, & 103 lconvection, & 104 lagespectra, & 105 ipin, & 106 ioutputforeachrelease, & 107 iflux, & 108 mdomainfill, & 109 ind_source, & 110 ind_receptor, & 111 mquasilag, & 112 nested_output, & 113 linit_cond, & 114 lnetcdfout, & 115 surf_only, & 116 iflagcbl, & 117 path_ohfields 118 119 ! Set default values for namelist 120 ldirect=0 121 ibdate=20000101 122 ibtime=0 123 iedate=20000102 124 ietime=0 125 loutstep=10800 126 loutaver=10800 127 loutsample=900 128 itsplit=999999999 129 lsynctime=900 130 ctl=-5.0 131 ifine=4 132 iout=3 133 ipout=0 134 lsubgrid=1 135 lconvection=1 136 lagespectra=0 137 ipin=1 138 ioutputforeachrelease=1 139 iflux=1 140 mdomainfill=0 141 ind_source=1 142 ind_receptor=1 143 mquasilag=0 144 nested_output=0 145 linit_cond=0 146 lnetcdfout=0 147 surf_only=0 148 iflagcbl=0 ! if using old-style COMMAND file, set to 1 here to use mc cbl routine 149 path_ohfields="../../flexin/" 149 150 150 151 !Af set release-switch 151 WETBKDEP=.false.152 DRYBKDEP=.false.153 152 wetbkdep=.false. 153 drybkdep=.false. 154 154 155 ! Open the command file and read user options 155 156 ! Namelist input first: try to read as namelist file … … 158 159 form='formatted',err=999) 159 160 160 ! try namelist input (default) 161 read(unitcommand, command,iostat=readerror)161 ! try namelist input 162 read(unitcommand, nml_command, iostat=ios) 162 163 close(unitcommand) 163 164 164 165 ! distinguish namelist from fixed text input 165 if ((readerror.ne.0).or.(ldirect.eq.0)) then ! parse as text file format 166 167 if (ios .ne. 0) then ! simple text file format 166 168 167 169 open(unitcommand,file=path(1)(1:length(1))//'COMMAND',status='old', err=999) 168 170 169 ! Check the format of the COMMAND file (either in free format,170 ! or using formatted mask)171 ! Check the format of the COMMAND file 172 ! (either in free format or using formatted mask) 171 173 ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION' 172 174 !************************************************************************** 173 175 174 176 call skplin(9,unitcommand) 175 read (unitcommand,901) line 176 901 format (a) 177 read (unitcommand,900) line 177 178 if (index(line,'LDIRECT') .eq. 0) then 178 179 old = .false. … … 243 244 ! Removed for backwards compatibility. 244 245 ! if (old) call skplin(3,unitcommand) !added by mc 245 ! read(unitcommand,*) cblflag!added by mc246 ! read(unitcommand,*) iflagcbl !added by mc 246 247 247 248 close(unitcommand) … … 252 253 if (nmlout.and.lroot) then 253 254 open(unitcommand,file=path(2)(1:length(2))//'COMMAND.namelist',err=998) 254 write(unitcommand,nml= command)255 write(unitcommand,nml=nml_command) 255 256 close(unitcommand) 256 257 endif … … 260 261 ! Determine how Markov chain is formulated (for w or for w/sigw) 261 262 !*************************************************************** 262 if ( cblflag.eq.1) then !---- added by mc to properlyset parameters for CBL simulations263 if (iflagcbl.eq.1) then !added by mc to set parameters for CBL simulations 263 264 turbswitch=.true. 264 if (lsynctime >maxtl) lsynctime=maxtl !maxtl defined in com_mod.f90265 if (lsynctime.gt.maxtl) lsynctime=maxtl !maxtl defined in com_mod.f90 265 266 if (ctl.lt.5) then 266 print *,'WARNING: CBL flag active the ratio of TLu/dthas been set to 5'267 print*,'WARNING: CBL flag active; ctl (TLu/dt) has been set to 5' 267 268 ctl=5. 268 end 269 if (ifine*ctl.lt.50 ) then269 endif 270 if (ifine*ctl.lt.50.) then 270 271 ifine=int(50./ctl)+1 271 272 print *,'WARNING: CBL flag active the ratio of TLW/dt was < 50, ifine has been re-set to',ifine 273 !pause 272 print *,'WARNING: CBL flag active; ctl (TLW/dt) was < 50,'// & 273 ' ifine has been re-set to', ifine 274 274 endif 275 print *,'WARNING: CBL flag active the ratio of TLW/dtis ',ctl*ifine276 print *,'WARNING: CBL flag activelsynctime is ',lsynctime275 print*,'WARNING: CBL flag active; reduced ctl is ',ctl*ifine 276 print*,'WARNING: CBL flag active; lsynctime is ',lsynctime 277 277 else !added by mc 278 ! note PS: shouldn't we print some msg as above also in the ntext case? 278 279 if (ctl.ge.0.1) then 279 280 turbswitch=.true. … … 286 287 ctl=1./ctl 287 288 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 289 ! Set the switches required for the various options for input/output units 290 !************************************************************************* 291 !AF Set the switches IND_REL and IND_SAMP for the release and sampling 292 !Af switches for the releasefile: 293 !Af IND_REL = 1 : xmass * rho 294 !Af IND_REL = 0 : xmass * 1 295 296 !Af switches for the conccalcfile: 297 !AF IND_SAMP = 0 : xmass * 1 298 !Af IND_SAMP = -1 : xmass / rho 299 300 !AF IND_SOURCE switches between different units for concentrations at the source 301 !Af NOTE that in backward simulations the release of computational particles 302 !Af takes place at the "receptor" and the sampling of p[articles at the "source". 303 !Af 1 = mass units 304 !Af 2 = mass mixing ratio units 305 !Af IND_RECEPTOR switches between different units for concentrations at the receptor 306 !Af 1 = mass units 307 !Af 2 = mass mixing ratio units 308 ! 3 = wet deposition in outputfield 309 ! 4 = dry deposition in outputfield 309 310 310 311 if ( ldirect .eq. 1 ) then ! FWD-Run … … 328 329 ind_samp = 0 329 330 endif 331 ! note PS: why do we suddenly switch to CASE syntax?? 332 ! not helpful. 330 333 select case (ind_receptor) 331 334 case (1) ! 1 .. concentration at receptor … … 337 340 if (lroot) then 338 341 write(*,*) ' #### FLEXPART WET DEPOSITION BACKWARD MODE #### ' 339 write(*,*) ' #### Release height is forced to 0 - 20km#### '342 write(*,*) ' #### Release height is forced to 0 - 20 km #### ' 340 343 write(*,*) ' #### Release is performed above ground lev #### ' 341 344 end if 342 WETBKDEP=.true.345 wetbkdep=.true. 343 346 allocate(xscav_frac1(maxpart,maxspec)) 344 347 case (4) ! 4 .. dry deposition in outputfield … … 349 352 write(*,*) ' #### Release is performed above ground lev #### ' 350 353 end if 351 DRYBKDEP=.true.354 drybkdep=.true. 352 355 allocate(xscav_frac1(maxpart,maxspec)) 353 356 end select … … 399 402 endif 400 403 401 ! Check for netcdf output switch 402 !******************************* 404 ! check for netcdf output switch (use for non-namelist input only!) 403 405 if (iout.ge.8) then 404 406 lnetcdfout = 1 405 407 iout = iout - 8 406 408 #ifndef USE_NCF 407 write(*,*) 'ERROR: netcdf output not activated during compile time but used in COMMAND file!' 408 write(*,*) 'Please recompile with netcdf library (`make [...] ncf=yes`) or use standard output format.' 409 write(*,*) 'ERROR: netcdf output not activated during compile '// & 410 'time but used in COMMAND file!' 411 write(*,*) 'Please recompile with netcdf library (`make [...] ncf=yes`)'//& 412 ' or use standard output format.' 409 413 stop 410 414 #endif … … 414 418 !********************************************************************** 415 419 416 if ( (iout.lt.1).or.(iout.gt.6)) then420 if (iout.lt.1 .or. iout.gt.6) then 417 421 write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND: #### ' 418 422 write(*,*) ' #### IOUT MUST BE 1, 2, 3, 4 OR 5 FOR #### ' … … 423 427 424 428 !AF check consistency between units and volume mixing ratio 425 if ( ( (iout.eq.2).or.(iout.eq.3)).and. &426 (ind_source.gt.1 .or. ind_receptor.gt.1) ) then429 if ( (iout.eq.2 .or. iout.eq.3) .and. & 430 (ind_source.gt.1 .or. ind_receptor.gt.1) ) then 427 431 write(*,*) ' #### FLEXPART MODEL ERROR! FILE COMMAND: #### ' 428 432 write(*,*) ' #### VOLUME MIXING RATIO ONLY SUPPORTED #### ' … … 479 483 480 484 ! For domain-filling trajectories, a plume centroid trajectory makes no sense, 481 ! For backward runs, only residence time output (iout=1) or plume trajectories (iout=4),482 ! or both (iout=5) makes sense; other output options are "forbidden"485 ! For backward runs, only residence time output (iout=1) or plume trajectories 486 ! (iout=4), or both (iout=5) makes sense; other output options are "forbidden" 483 487 !***************************************************************************** 484 488 … … 649 653 path(2)(1:length(2))//'COMMAND.namelist' 650 654 stop 'stopped in readcommand' 655 651 656 999 write(*,900) ' #### FLEXPART MODEL ERROR! FILE "COMMAND"' 652 657 write(*,900) ' #### CANNOT OPEN '//path(1)(1:length(1))//'COMMAND' 653 658 stop 'stopped in readcommand' 654 900 format (a) 659 660 900 format(a) 661 655 662 end subroutine readcommand -
src/readoutgrid.f90
r8a65cb0 rd7935de 29 29 ! * 30 30 ! 4 June 1996 * 31 ! HSO, 1 July 2014 32 ! Added optional namelist input 31 ! HSO, 1 July 2014: Add optional namelist input * 32 ! PS, 6/2015-9/2018: read regular input with free format * 33 ! simplify code and rename some variables * 33 34 ! * 34 35 !***************************************************************************** … … 51 52 implicit none 52 53 53 integer :: i, j,stat54 real :: outhelp,xr,xr1,yr,yr154 integer :: i,kz,istat 55 real :: xr,xr1,yr,yr1 55 56 real,parameter :: eps=1.e-4 56 57 57 58 ! namelist variables 58 59 integer, parameter :: maxoutlev=500 59 integer :: readerror 60 real,allocatable, dimension (:) :: outheights 60 integer :: ios 61 real,allocatable, dimension (:) :: outheights,outaux 62 logical :: lnml 61 63 62 64 ! declare namelist 63 namelist / outgrid/ &65 namelist /nml_outgrid/ & 64 66 outlon0,outlat0, & 65 67 numxgrid,numygrid, & 66 68 dxout,dyout, & 67 outheights 68 69 ! allocate large array for reading input 70 allocate(outheights(maxoutlev),stat=stat) 71 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights' 72 73 ! helps identifying failed namelist input 74 dxout=-1.0 75 outheights=-1.0 69 outheight 70 71 ! allocate outheights for nml read with max dimension 72 allocate(outheights(maxoutlev),outaux(maxoutlev),stat=istat) 73 if (istat .ne. 0) write(*,*)'ERROR: could not allocate outheights' 76 74 77 75 ! Open the OUTGRID file and read output grid specifications 78 76 !********************************************************** 79 77 80 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',form='formatted',err=999) 78 outheight(:) = -999. ! initialise for later finding #valid levels 79 open(unitoutgrid,file=trim(path(1))//'OUTGRID',status='old',& 80 form='formatted',err=999) 81 81 82 82 ! try namelist input 83 read(unitoutgrid, outgrid,iostat=readerror)83 read(unitoutgrid,nml_outgrid,iostat=ios) 84 84 close(unitoutgrid) 85 85 86 if ((dxout.le.0).or.(readerror.ne.0)) then 87 88 readerror=1 89 90 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',err=999) 91 86 if (ios .eq. 0) then ! namelist works 87 88 lnml = .true. 89 90 else ! read as regular text 91 92 lnml = .false. 93 94 open(unitoutgrid,file=trim(path(1))//'OUTGRID',status='old',err=999) 92 95 call skplin(5,unitoutgrid) 93 96 94 ! 1.Read horizontal grid specifications97 ! Read horizontal grid specifications 95 98 !**************************************** 96 99 97 100 call skplin(3,unitoutgrid) 98 read(unitoutgrid, '(4x,f11.4)') outlon099 call skplin(3,unitoutgrid) 100 read(unitoutgrid, '(4x,f11.4)') outlat0101 call skplin(3,unitoutgrid) 102 read(unitoutgrid, '(4x,i5)') numxgrid103 call skplin(3,unitoutgrid) 104 read(unitoutgrid, '(4x,i5)') numygrid105 call skplin(3,unitoutgrid) 106 read(unitoutgrid, '(4x,f12.5)') dxout107 call skplin(3,unitoutgrid) 108 read(unitoutgrid, '(4x,f12.5)') dyout109 110 endif 101 read(unitoutgrid,*) outlon0 102 call skplin(3,unitoutgrid) 103 read(unitoutgrid,*) outlat0 104 call skplin(3,unitoutgrid) 105 read(unitoutgrid,*) numxgrid 106 call skplin(3,unitoutgrid) 107 read(unitoutgrid,*) numygrid 108 call skplin(3,unitoutgrid) 109 read(unitoutgrid,*) dxout 110 call skplin(3,unitoutgrid) 111 read(unitoutgrid,*) dyout 112 113 endif ! read OUTGRID file 111 114 112 115 ! Check validity of output grid (shall be within model domain) … … 124 127 write(*,*) ' #### GRID IS OUTSIDE MODEL DOMAIN. CHANGE ####' 125 128 write(*,*) ' #### FILE OUTGRID IN DIRECTORY ####' 126 write(*,'(a)') path(1)(1:length(1))129 write(*,'(a)') trim(path(1)) 127 130 stop 128 131 endif 129 132 130 ! 2. Count Vertical levels of output grid 131 !**************************************** 132 133 if (readerror.ne.0) then 134 j=0 135 100 j=j+1 136 do i=1,3 137 read(unitoutgrid,*,end=99) 138 end do 139 read(unitoutgrid,'(4x,f7.1)',end=99) outhelp 140 if (outhelp.eq.0.) goto 99 141 goto 100 142 99 numzgrid=j-1 143 else 144 do i=1,maxoutlev 145 if (outheights(i).lt.0) exit 146 end do 147 numzgrid=i-1 148 end if 149 150 allocate(outheight(numzgrid),stat=stat) 151 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheight' 152 allocate(outheighthalf(numzgrid),stat=stat) 153 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheighthalf' 154 155 ! 2. Vertical levels of output grid 156 !********************************** 157 158 if (readerror.ne.0) then 159 160 rewind(unitoutgrid) 161 call skplin(29,unitoutgrid) 162 163 do j=1,numzgrid 164 do i=1,3 165 read(unitoutgrid,*) 166 end do 167 read(unitoutgrid,'(4x,f7.1)') outhelp 168 outheight(j)=outhelp 169 outheights(j)=outhelp 170 end do 171 close(unitoutgrid) 172 173 else 174 175 do j=1,numzgrid 176 outheight(j)=outheights(j) 177 end do 178 133 ! Read (if .not. lmnl) and count vertical levels of output grid 134 !************************************************************** 135 136 do kz = 1,maxoutlev 137 if (lnml) then ! we have read them already 138 if (outheight(kz) .lt. 0.) exit ! 1st nondefined level 139 else 140 call skplin(3,unitoutgrid) 141 read(unitoutgrid,*,end=10) outheight(kz) 142 endif 143 end do 144 10 continue 145 146 numzgrid = kz - 1 ! number of outgrid levels 147 148 ! allocate the required length only, shuffle data 149 outaux = outheight ! shuffle 150 151 deallocate(outheights) 152 allocate(outheight(numzgrid),outheighthalf(numzgrid),stat=istat) 153 if (istat .ne. 0) then 154 write(*,*) 'ERROR: could not allocate outheight and outheighthalf' 155 stop 'readoutgrid error' 179 156 endif 180 157 181 ! write outgrid file in namelist format to output directory if requested 182 if (nmlout.and.lroot) then 183 ! reallocate outheights with actually required dimension for namelist writing 184 deallocate(outheights) 185 allocate(outheights(numzgrid),stat=stat) 186 if (stat.ne.0) write(*,*)'ERROR: could not allocate outheights' 187 188 do j=1,numzgrid 189 outheights(j)=outheight(j) 190 end do 191 192 open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID.namelist',err=1000) 193 write(unitoutgrid,nml=outgrid) 158 outheight=outaux(1:numzgrid) ! shuffle back 159 deallocate (outaux) 160 161 ! write outgrid file in namelist format to output directory if requested 162 if (nmlout) then 163 open(unitoutgrid,file=trim(path(2))//'OUTGRID.namelist',err=1000) 164 write(unitoutgrid,nml=nml_outgrid) 194 165 close(unitoutgrid) 195 166 endif … … 198 169 !*************************************************************** 199 170 200 do j=2,numzgrid 201 if (outheight(j).le.outheight(j-1)) then 202 write(*,*) ' #### FLEXPART MODEL ERROR! YOUR SPECIFICATION#### ' 203 write(*,*) ' #### OF OUTPUT LEVELS IS CORRUPT AT LEVEL #### ' 204 write(*,*) ' #### ',j,' #### ' 205 write(*,*) ' #### PLEASE MAKE CHANGES IN FILE OUTGRID. #### ' 206 endif 171 do kz=2,numzgrid 172 if (outheight(kz) .le. outheight(kz-1)) goto 998 207 173 end do 208 174 … … 210 176 !***************************************************************** 211 177 212 outheighthalf(1) =outheight(1)/2.213 do j=2,numzgrid214 outheighthalf( j)=(outheight(j-1)+outheight(j))/2.178 outheighthalf(1) = 0.5*outheight(1) 179 do kz = 2,numzgrid 180 outheighthalf(kz) = 0.5*(outheight(kz-1)+outheight(kz)) 215 181 end do 216 182 … … 218 184 youtshift=ylat0-outlat0 219 185 220 allocate(oroout(0:numxgrid-1,0:numygrid-1),stat=stat) 221 if (stat.ne.0) write(*,*)'ERROR: could not allocate oroout' 222 allocate(area(0:numxgrid-1,0:numygrid-1),stat=stat) 223 if (stat.ne.0) write(*,*)'ERROR: could not allocate area' 224 allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat) 225 if (stat.ne.0) write(*,*)'ERROR: could not allocate volume' 226 allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat) 227 if (stat.ne.0) write(*,*)'ERROR: could not allocate areaeast' 228 allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid),stat=stat) 229 if (stat.ne.0) write(*,*)'ERROR: could not allocate areanorth' 186 allocate(oroout(0:numxgrid-1,0:numygrid-1),stat=istat) 187 if (istat .ne. 0) write(*,*)'ERROR: could not allocate oroout' 188 allocate(area(0:numxgrid-1,0:numygrid-1),stat=istat) 189 if (istat .ne. 0) write(*,*)'ERROR: could not allocate area' 190 allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat) 191 if (istat .ne. 0) write(*,*)'ERROR: could not allocate volume' 192 allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat) 193 if (istat .ne. 0) write(*,*)'ERROR: could not allocate areaeast' 194 allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid),stat=istat) 195 if (istat .ne. 0) write(*,*)'ERROR: could not allocate areanorth' 196 230 197 return 231 198 199 998 continue 200 write(*,*) ' #### FLEXPART MODEL ERROR! YOUR SPECIFICATION#### ' 201 write(*,*) ' #### OF OUTPUT LEVELS NOT INCREASING AT LEVEL#### ' 202 write(*,*) ' #### ',kz,' #### ' 203 write(*,*) ' #### PLEASE MAKE CHANGES IN FILE OUTGRID. #### ' 204 STOP 'readoutgrid error' 232 205 233 206 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 234 207 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 235 write(*,'(a)') path(1)(1:length(1))208 write(*,'(a)') trim(path(1)) 236 209 stop 237 210 238 211 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 239 212 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 240 write(*,'(a)') path(2)(1:length(2))213 write(*,'(a)') trim(path(2)) 241 214 stop 242 215 -
src/readoutgrid_nest.f90
r8a65cb0 rd7935de 29 29 ! * 30 30 ! 4 June 1996 * 31 ! HSO, 1 July 2014: Add optional namelist input * 32 ! PS, 6/2015-9/2018: read regular input with free format * 33 ! and rename some variables * 31 34 ! * 32 35 !***************************************************************************** … … 53 56 real,parameter :: eps=1.e-4 54 57 55 integer :: readerror58 integer :: ios 56 59 57 ! declare namelist 58 namelist /outgridn/ & 59 outlon0n,outlat0n, & 60 numxgridn,numygridn, & 61 dxoutn,dyoutn 60 ! declare namelist 61 namelist /nml_outgridn/ & 62 outlon0n,outlat0n,numxgridn,numygridn,dxoutn,dyoutn 62 63 63 64 ! helps identifying failed namelist input … … 67 68 !********************************************************** 68 69 69 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',form='formatted',status='old',err=999) 70 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',form='formatted',& 71 status='old',err=999) 70 72 71 73 ! try namelist input 72 read(unitoutgrid, outgridn,iostat=readerror)74 read(unitoutgrid,nml_outgridn,iostat=ios) 73 75 close(unitoutgrid) 74 76 75 if ( (dxoutn.le.0).or.(readerror.ne.0)) then77 if (dxoutn.le.0 .or.ios.ne.0) then 76 78 77 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',status='old',err=999) 79 open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID_NEST',status='old',& 80 err=999) 78 81 call skplin(5,unitoutgrid) 79 82 80 ! 1.Read horizontal grid specifications81 !****************************************83 ! Read horizontal grid specifications 84 ! *********************************** 82 85 83 86 call skplin(3,unitoutgrid) 84 read(unitoutgrid, '(4x,f11.4)') outlon0n87 read(unitoutgrid,*) outlon0n 85 88 call skplin(3,unitoutgrid) 86 read(unitoutgrid, '(4x,f11.4)') outlat0n89 read(unitoutgrid,*) outlat0n 87 90 call skplin(3,unitoutgrid) 88 read(unitoutgrid, '(4x,i5)') numxgridn91 read(unitoutgrid,*) numxgridn 89 92 call skplin(3,unitoutgrid) 90 read(unitoutgrid, '(4x,i5)') numygridn93 read(unitoutgrid,*) numygridn 91 94 call skplin(3,unitoutgrid) 92 read(unitoutgrid, '(4x,f12.5)') dxoutn95 read(unitoutgrid,*) dxoutn 93 96 call skplin(3,unitoutgrid) 94 read(unitoutgrid, '(4x,f12.5)') dyoutn97 read(unitoutgrid,*) dyoutn 95 98 96 99 close(unitoutgrid) … … 99 102 ! write outgrid_nest file in namelist format to output directory if requested 100 103 if (nmlout.and.lroot) then 101 open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID_NEST.namelist',err=1000) 102 write(unitoutgrid,nml=outgridn) 104 open(unitoutgrid,file=path(2)(1:length(2))//'OUTGRID_NEST.namelist',& 105 err=1000) 106 write(unitoutgrid,nml=nml_outgridn) 103 107 close(unitoutgrid) 104 108 endif 105 109 106 allocate(orooutn(0:numxgridn-1,0:numygridn-1),stat= stat)107 if ( stat.ne.0) write(*,*)'ERROR: could not allocate orooutn'108 allocate(arean(0:numxgridn-1,0:numygridn-1),stat= stat)109 if ( stat.ne.0) write(*,*)'ERROR: could not allocate arean'110 allocate(volumen(0:numxgridn-1,0:numygridn-1,numzgrid),stat= stat)111 if ( stat.ne.0) write(*,*)'ERROR: could not allocate volumen'110 allocate(orooutn(0:numxgridn-1,0:numygridn-1),stat=ios) 111 if (ios.ne.0) write(*,*)'ERROR: could not allocate orooutn' 112 allocate(arean(0:numxgridn-1,0:numygridn-1),stat=ios) 113 if (ios.ne.0) write(*,*)'ERROR: could not allocate arean' 114 allocate(volumen(0:numxgridn-1,0:numygridn-1,numzgrid),stat=ios) 115 if (ios.ne.0) write(*,*)'ERROR: could not allocate volumen' 112 116 113 117 ! Check validity of output grid (shall be within model domain) … … 118 122 xr1=xlon0+real(nxmin1)*dx 119 123 yr1=ylat0+real(nymin1)*dy 120 if ( (outlon0n+eps.lt.xlon0).or.(outlat0n+eps.lt.ylat0)&121 .or.(xr.gt.xr1+eps).or.(yr.gt.yr1+eps)) then124 if (outlon0n+eps.lt.xlon0 .or. outlat0n+eps.lt.ylat0 & 125 .or. xr.gt.xr1+eps .or. yr.gt.yr1+eps) then 122 126 write(*,*) ' #### FLEXPART MODEL ERROR! PART OF OUTPUT ####' 123 127 write(*,*) ' #### NEST IS OUTSIDE MODEL DOMAIN. CHANGE ####' 124 128 write(*,*) ' #### FILE OUTGRID IN DIRECTORY ####' 125 write(*,'(a)') path(1)(1:length(1))129 write(*,'(a)') trim(path(1)) 126 130 stop 127 131 endif … … 133 137 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 134 138 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 135 write(*,'(a)') path(1)(1:length(1))139 write(*,'(a)') trim(path(1)) 136 140 stop 137 141 138 142 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID" #### ' 139 143 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 140 write(*,'(a)') path(2)(1:length(2))144 write(*,'(a)') trim(path(2)) 141 145 stop 142 146 -
src/readreceptors.f90
r8a65cb0 rd7935de 27 27 ! * 28 28 ! Author: A. Stohl * 29 ! 1 August 1996 * 30 ! HSO, 14 August 2013 31 ! Added optional namelist input 29 ! 1 August 1996 30 ! * 31 ! HSO, 14 August 2013: Added optional namelist input 32 ! PS, 2/2015: access= -> position= 33 ! PS, 6/2015: variable names, simplify code 32 34 ! * 33 35 !***************************************************************************** … … 52 54 character(len=16) :: receptor 53 55 54 integer :: readerror55 real :: lon,lat ! for namelist input, lon/lat are used instead of x,y56 integer :: ios 57 real :: xlon,ylat ! for namelist input, lon/lat are used instead of x,y 56 58 integer,parameter :: unitreceptorout=2 57 59 58 60 ! declare namelist 59 namelist /receptors/ & 60 receptor, lon, lat 61 namelist /nml_receptors/ receptor, xlon, ylat 61 62 62 lon=-999.9 63 64 ! For backward runs, do not allow receptor output. Thus, set number ofreceptors to zero63 !CPS I comment this out - why should we not have receptor output in bwd runs? 64 ! For backward runs, do not allow receptor output. Thus, set number of 65 ! receptors to zero 65 66 !***************************************************************************** 66 67 67 if (ldirect.lt.0) then68 numreceptor=069 return70 endif68 ! if (ldirect.lt.0) then 69 ! numreceptor=0 70 ! return 71 ! endif 71 72 72 73 … … 74 75 !************************************************************ 75 76 76 open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',form='formatted',status='old',err=999) 77 open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',form='formatted',& 78 status='old',err=999) 77 79 78 80 ! try namelist input 79 read(unitreceptor, receptors,iostat=readerror)81 read(unitreceptor,nml_receptors,iostat=ios) 80 82 81 83 ! prepare namelist output if requested 82 if (nmlout.and.lroot) then 83 open(unitreceptorout,file=path(2)(1:length(2))//'RECEPTORS.namelist',& 84 &access='append',status='replace',err=1000) 85 endif 84 if (nmlout) open(unitreceptorout,file=path(2)(1:length(2))// & 85 'RECEPTORS.namelist', position='append',status='new',err=1000) 86 86 87 if ( (lon.lt.-900).or.(readerror.ne.0)) then87 if (ios .ne. 0) then ! read as regular text file 88 88 89 89 close(unitreceptor) 90 open(unitreceptor,file=path(1)(1:length(1))//'RECEPTORS',status='old',err=999) 90 open(unitreceptor,file=path(1)(1:length(1))// & 91 'RECEPTORS',status='old',err=999) 92 91 93 call skplin(5,unitreceptor) 92 94 … … 101 103 read(unitreceptor,'(4x,a16)',end=99) receptor 102 104 call skplin(3,unitreceptor) 103 read(unitreceptor,'(4x,f11.4)',end=99) x105 read(unitreceptor,'(4x,f11.4)',end=99) xlon 104 106 call skplin(3,unitreceptor) 105 read(unitreceptor,'(4x,f11.4)',end=99) y106 if ((x.eq.0.).and.(y.eq.0.).and. &107 read(unitreceptor,'(4x,f11.4)',end=99) ylat 108 if ((xlon.eq.0.).and.(ylat.eq.0.).and. & 107 109 (receptor.eq.' ')) then 108 110 j=j-1 … … 116 118 endif 117 119 receptorname(j)=receptor 118 xreceptor(j)=(x-xlon0)/dx ! transform to grid coordinates119 yreceptor(j)=(y-ylat0)/dy120 xm=r_earth*cos(y*pi/180.)*dx/180.*pi120 xreceptor(j)=(xlon-xlon0)/dx ! transform to grid coordinates 121 yreceptor(j)=(ylat-ylat0)/dy 122 xm=r_earth*cos(ylat*pi/180.)*dx/180.*pi 121 123 ym=r_earth*dy/180.*pi 122 124 receptorarea(j)=xm*ym 123 124 ! write receptors file in namelist format to output directory if requested 125 if (nmlout.and.lroot) then 126 lon=x 127 lat=y 128 write(unitreceptorout,nml=receptors) 129 endif 125 ! write receptors file in namelist format to output directory if requested 126 if (nmlout.and.lroot) write(unitreceptorout,nml=nml_receptors) 130 127 131 128 goto 100 … … 136 133 137 134 j=0 138 do while ( readerror.eq.0)135 do while (ios .eq. 0) 139 136 j=j+1 140 lon=-999.9 141 read(unitreceptor,receptors,iostat=readerror) 142 if ((lon.lt.-900).or.(readerror.ne.0)) then 143 readerror=1 144 else 137 read(unitreceptor,nml_receptors,iostat=ios) 138 if (ios .eq. 0) then 145 139 if (j.gt.maxreceptor) then 146 140 write(*,*) ' #### FLEXPART MODEL ERROR! TOO MANY RECEPTOR #### ' … … 150 144 endif 151 145 receptorname(j)=receptor 152 xreceptor(j)=( lon-xlon0)/dx ! transform to grid coordinates153 yreceptor(j)=( lat-ylat0)/dy154 xm=r_earth*cos( lat*pi/180.)*dx/180.*pi146 xreceptor(j)=(xlon-xlon0)/dx ! transform to grid coordinates 147 yreceptor(j)=(ylat-ylat0)/dy 148 xm=r_earth*cos(ylat*pi/180.)*dx/180.*pi 155 149 ym=r_earth*dy/180.*pi 156 150 receptorarea(j)=xm*ym 157 151 endif 158 152 159 ! write receptors file in namelist format to output directory if requested 160 if (nmlout.and.lroot) then 161 write(unitreceptorout,nml=receptors) 162 endif 153 ! write receptors file in namelist format to output directory if requested 154 if (nmlout.and.lroot) write(unitreceptorout,nml=nml_receptors) 163 155 164 156 end do … … 166 158 close(unitreceptor) 167 159 168 endif 160 endif ! end no-nml / nml bloc 169 161 170 if (nmlout.and.lroot) then 171 close(unitreceptorout) 172 endif 162 if (nmlout .and. lroot) close(unitreceptorout) 173 163 174 164 return … … 176 166 177 167 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS" #### ' 178 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### '179 write(*,'(a)') path(1)(1:length(1))168 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 169 write(*,'(a)') trim(path(1)) 180 170 stop 181 171 182 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS" 183 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### '184 write(*,'(a)') path(2)(1:length(2))172 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RECEPTORS" #### ' 173 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 174 write(*,'(a)') trim(path(2)) 185 175 stop 186 176 -
src/readreleases.f90
r5184a7c rd7935de 33 33 ! Update: 29 January 2001 * 34 34 ! Release altitude can be either in magl or masl * 35 ! HSO, 12 August 2013 36 ! Added optional namelist input 35 ! HSO, 12 August 2013: Added optional namelist input * 36 ! PS, 2/2015: access= -> position= (ported from 9.2 review) * 37 ! PS, 8/2018: check for uninitialised mass (ticket:204), * 38 ! rename int/real variables, a bit of code layout improvement * 37 39 ! * 38 40 !***************************************************************************** … … 74 76 implicit none 75 77 76 integer :: numpartmax,i,j,id1,it1,id2,it2,idum, stat,irel,ispc,nsettle78 integer :: numpartmax,i,j,id1,it1,id2,it2,idum,iallocstat,irel,ispc,nsettle 77 79 integer,parameter :: num_min_discrete=100 78 80 real :: vsh(ni),fracth(ni),schmih(ni),releaserate,xdum,cun 79 81 real(kind=dp) :: jul1,jul2,julm,juldate 80 real,parameter :: eps2=1.e-981 82 character(len=50) :: line 82 83 logical :: old 83 84 84 85 ! help variables for namelist reading 85 integer :: numpoints, parts, readerror86 integer*2 :: zkind86 integer :: numpoints, nparts, ios 87 integer*2 :: ikindz 87 88 integer :: idate1, itime1, idate2, itime2 88 real :: lon1,lon2,lat1,lat2,z1,z289 real :: rlon1,rlon2,rlat1,rlat2,z1,z2 89 90 character*40 :: comment 90 91 integer,parameter :: unitreleasesout=2 91 real,allocatable, dimension (:) :: mass92 integer,allocatable, dimension (:) :: specnum_rel,specnum_rel292 real,allocatable, dimension (:) :: rmass 93 integer,allocatable, dimension (:) :: numspec_rel,numspec_rel2 93 94 94 95 ! declare namelists 95 96 namelist /releases_ctrl/ & 96 97 nspec, & 97 specnum_rel98 numspec_rel 98 99 99 100 namelist /release/ & 100 101 idate1, itime1, & 101 102 idate2, itime2, & 102 lon1,lon2, &103 lat1,lat2, &103 rlon1, rlon2, & 104 rlat1, rlat2, & 104 105 z1, z2, & 105 zkind, &106 mass, &107 parts, &106 ikindz, & 107 rmass, & 108 nparts, & 108 109 comment 110 ! initialiase mass 109 111 110 112 numpoint=0 111 113 112 113 allocate( mass(maxspec),stat=stat)114 if ( stat.ne.0) write(*,*)'ERROR: could not allocatemass'115 allocate( specnum_rel(maxspec),stat=stat)116 if ( stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel'117 118 114 ! allocate with maxspec for first input loop 115 allocate(rmass(maxspec),stat=iallocstat) 116 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate rmass' 117 allocate(numspec_rel(maxspec),stat=iallocstat) 118 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel' 119 120 ! presetting namelist releases_ctrl 119 121 nspec = -1 ! use negative value to determine failed namelist input 120 specnum_rel = 0 121 122 !sec, read release to find how many releasepoints should be allocated 123 open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',form='formatted',err=999) 124 125 ! check if namelist input provided 126 read(unitreleases,releases_ctrl,iostat=readerror) 127 128 ! prepare namelist output if requested 122 numspec_rel = 0 123 124 !SEC: read release to find how many releasepoints should be allocated 125 open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old', & 126 form='formatted',err=999) 127 128 ! prepare namelist output if requested 129 129 if (nmlout.and.lroot) then 130 open(unitreleasesout,file=path(2)(1:length(2))//'RELEASES.namelist',access='append',status='replace',err=1000) 131 endif 132 133 if ((readerror.ne.0).or.(nspec.lt.0)) then 134 135 ! no namelist format, close file and allow reopening in old format 130 open(unitreleasesout,file=path(2)(1:length(2))//'RELEASES.namelist', & 131 position='append',status='replace',err=1000) 132 endif 133 134 ! check whether namelist input is available 135 read(unitreleases,releases_ctrl,iostat=ios) 136 137 if (ios .ne. 0 .or. nspec .lt. 0 ) then 138 139 ! not in namelist format, close file and reopen as simple text file 140 136 141 close(unitreleases) 137 open(unitreleases,file=path(1)(1:length(1))//'RELEASES',status='old',err=999) 138 139 readerror=1 ! indicates old format 140 141 ! Check the format of the RELEASES file (either in free format, 142 ! or using a formatted mask) 142 open(unitreleases,file=path(1)(1:length(1))//'RELEASES', status='old', & 143 err=999) 144 145 ios=1 ! indicates old format 146 147 ! Check the format of the RELEASES file 148 ! (either in free format, or using a formatted mask) 143 149 ! Use of formatted mask is assumed if line 10 contains the word 'DIRECTION' 144 150 !************************************************************************** 151 ! Note PS: something has changed, now Total is checked. Is this compatible?? 145 152 146 153 call skplin(12,unitreleases) … … 163 170 if (old) call skplin(2,unitreleases) 164 171 do i=1,nspec 165 read(unitreleases,*,err=998) specnum_rel(i)172 read(unitreleases,*,err=998) numspec_rel(i) 166 173 if (old) call skplin(2,unitreleases) 167 174 end do … … 202 209 25 numpoint=numpoint-1 203 210 204 else 205 206 readerror=0207 do while ( readerror.eq.0)211 else ! read namelist input 212 213 ios=0 214 do while (ios.eq.0) ! loop over release points 208 215 idate1=-1 209 read(unitreleases,release,iostat= readerror)210 if ( (idate1.lt.0).or.(readerror.ne.0)) then211 readerror=1216 read(unitreleases,release,iostat=ios) 217 if (idate1.lt.0 .or. ios.ne.0) then 218 ios=1 212 219 else 213 220 numpoint=numpoint+1 214 221 endif 215 222 end do 216 readerror=0 217 endif ! if namelist input 223 ios=0 224 225 endif 218 226 219 227 rewind(unitreleases) … … 221 229 if (nspec.gt.maxspec) goto 994 222 230 223 ! allocate arrays of matching size for number of species (namelist output) 224 deallocate(mass) 225 allocate(mass(nspec),stat=stat) 226 if (stat.ne.0) write(*,*)'ERROR: could not allocate mass' 227 allocate(specnum_rel2(nspec),stat=stat) 228 if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel2' 229 specnum_rel2=specnum_rel(1:nspec) 230 deallocate(specnum_rel) 231 ! allocate arrays of matching size for number of species (namelist output) 232 deallocate(rmass) 233 allocate(rmass(nspec),stat=iallocstat) 234 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate rmass' 235 allocate(numspec_rel2(nspec),stat=iallocstat) 236 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel2' 237 238 numspec_rel2 = numspec_rel(1:nspec) 239 240 deallocate(numspec_rel) 231 241 ! eso: BUG, crashes here for nspec=12 and maxspec=6, 232 242 ! TODO: catch error and exit 233 allocate(specnum_rel(nspec),stat=stat) 234 if (stat.ne.0) write(*,*)'ERROR: could not allocate specnum_rel' 235 specnum_rel=specnum_rel2 236 deallocate(specnum_rel2) 237 238 !allocate memory for numpoint releaspoints 239 allocate(ireleasestart(numpoint),stat=stat) 240 if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleasestart' 241 allocate(ireleaseend(numpoint),stat=stat) 242 if (stat.ne.0) write(*,*)'ERROR: could not allocate ireleaseend' 243 allocate(xpoint1(numpoint),stat=stat) 244 if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint1' 245 allocate(xpoint2(numpoint),stat=stat) 246 if (stat.ne.0) write(*,*)'ERROR: could not allocate xpoint2' 247 allocate(ypoint1(numpoint),stat=stat) 248 if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint1' 249 allocate(ypoint2(numpoint),stat=stat) 250 if (stat.ne.0) write(*,*)'ERROR: could not allocate ypoint2' 251 allocate(zpoint1(numpoint),stat=stat) 252 if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint1' 253 allocate(zpoint2(numpoint),stat=stat) 254 if (stat.ne.0) write(*,*)'ERROR: could not allocate zpoint2' 255 allocate(kindz(numpoint),stat=stat) 256 if (stat.ne.0) write(*,*)'ERROR: could not allocate kindz' 257 allocate(xmass(numpoint,maxspec),stat=stat) 258 if (stat.ne.0) write(*,*)'ERROR: could not allocate xmass' 259 allocate(rho_rel(numpoint),stat=stat) 260 if (stat.ne.0) write(*,*)'ERROR: could not allocate rho_rel' 261 allocate(npart(numpoint),stat=stat) 262 if (stat.ne.0) write(*,*)'ERROR: could not allocate npart' 263 allocate(xmasssave(numpoint),stat=stat) 264 if (stat.ne.0) write(*,*)'ERROR: could not allocate xmasssave' 265 266 if (lroot) write (*,*) 'Releasepoints : ', numpoint 267 268 do i=1,numpoint 269 xmasssave(i)=0. 270 end do 243 allocate(numspec_rel(nspec),stat=iallocstat) 244 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate numspec_rel' 245 246 numspec_rel = numspec_rel2 247 248 deallocate(numspec_rel2) 249 250 ! allocate memory for numpoint releaspoints 251 allocate ( & 252 ireleasestart(numpoint), ireleaseend(numpoint),xpoint1(numpoint), & 253 xpoint2(numpoint), ypoint1(numpoint), ypoint2(numpoint), & 254 zpoint1(numpoint), zpoint2(numpoint), kindz(numpoint), & 255 xmass(numpoint,maxspec), rho_rel(numpoint), npart(numpoint), & 256 xmasssave(numpoint), & 257 stat=iallocstat ) 258 if (iallocstat.ne.0) write(*,*)'ERROR: could not allocate variables' // & 259 ' dimensioned numpoint =', numpoint 260 261 if (lroot) write (*,*) 'Release points : ', numpoint 262 263 xmasssave(:)=0. 271 264 272 265 !now save the information 273 DEP=.false. 274 DRYDEP=.false. 275 WETDEP=.false. 276 OHREA=.false. 277 do i=1,maxspec 278 DRYDEPSPEC(i)=.false. 279 WETDEPSPEC(i)=.false. 280 end do 281 282 if (readerror.ne.0) then 266 dep =.false. 267 drydep=.false. 268 wetdep=.false. 269 ohrea =.false. 270 drydepspec(:)=.false. 271 wetdepspec(:)=.false. 272 273 if (ios.ne.0) then 274 283 275 ! Skip first 11 lines (file header) 284 276 !********************************** … … 292 284 if (nspec.gt.maxspec) goto 994 293 285 if (old) call skplin(2,unitreleases) 294 endif 295 296 ! namelist output 297 if (nmlout.and.lroot) then 298 299 endif 300 286 287 endif 288 289 ! namelist output 290 if (nmlout.and.lroot) write(unitreleasesout,nml=releases_ctrl) 291 292 ! species loop 301 293 do i=1,nspec 302 if (readerror.ne.0) then 303 read(unitreleases,*,err=998) specnum_rel(i) 294 295 if (ios.ne.0) then 296 read(unitreleases,*,err=998) numspec_rel(i) 304 297 if (old) call skplin(2,unitreleases) 305 call readspecies( specnum_rel(i),i)298 call readspecies(numspec_rel(i),i) 306 299 else 307 call readspecies( specnum_rel(i),i)300 call readspecies(numspec_rel(i),i) 308 301 endif 309 302 … … 322 315 !***************** 323 316 324 if ( ((iout.eq.2).or.(iout.eq.3)).and.(weightmolar(i).lt.0.)) then317 if ( (iout.eq.2 .or. iout.eq.3) .and. weightmolar(i).lt.0. ) then 325 318 write(*,*) 'For mixing ratio output, valid molar weight' 326 319 write(*,*) 'must be specified for all simulated species.' … … 334 327 335 328 decay(i)=0.693147/decay(i) !conversion half life to decay constant 336 329 ! Note PS: this should be replace by = alog(2.)/decay(i) 330 ! keep it for the moment so that results are not affect in test phase of v10 337 331 338 332 ! Dry deposition of gases 339 333 !************************ 340 334 341 if (reldiff(i).gt.0.) rm(i)=1./( henry(i)/3000.+100.*f0(i))! mesophyll resistance335 if (reldiff(i).gt.0.) rm(i)=1./( henry(i)/3000. + 100.*f0(i) )! mesophyll resistance 342 336 343 337 ! Dry deposition of particles 344 338 !**************************** 345 339 346 vsetaver(i) =0.347 cunningham(i) =0.348 dquer(i) =dquer(i)*1000000.! Conversion m to um340 vsetaver(i) = 0. 341 cunningham(i) = 0. 342 dquer(i) = dquer(i)*1.e6 ! Conversion m to um 349 343 if (density(i).gt.0.) then ! Additional parameters 350 344 call part0(dquer(i),dsigma(i),density(i),fracth,schmih,cun,vsh) 351 345 do j=1,ni 352 fract(i,j) =fracth(j)353 schmi(i,j) =schmih(j)354 vset(i,j) =vsh(j)355 cunningham(i) =cunningham(i)+cun*fract(i,j)356 vsetaver(i) =vsetaver(i)-vset(i,j)*fract(i,j)346 fract(i,j) = fracth(j) 347 schmi(i,j) = schmih(j) 348 vset(i,j) = vsh(j) 349 cunningham(i) = cunningham(i) + cun*fract(i,j) 350 vsetaver(i) = vsetaver(i) - vset(i,j)*fract(i,j) 357 351 end do 358 352 if (lroot) write(*,*) 'Average settling velocity: ',i,vsetaver(i) … … 368 362 369 363 ! ESO 04.2016 check for below-cloud scavenging (gas or aerosol) 370 if ((dquer(i).le.0..and.(weta_gas(i).gt.0. .or. wetb_gas(i).gt.0.)) .or. & 371 &(dquer(i).gt.0. .and. (crain_aero(i) .gt. 0. .or. csnow_aero(i).gt.0.))) then 372 WETDEP=.true. 373 WETDEPSPEC(i)=.true. 364 if ( & 365 dquer(i).le.0. .and. (weta_gas(i) .gt.0. .or. wetb_gas(i) .gt.0.) .or. & 366 dquer(i).gt.0. .and. (crain_aero(i).gt.0. .or. csnow_aero(i).gt.0.) & 367 ) then 368 wetdep = .true. 369 wetdepspec(i) = .true. 374 370 if (lroot) then 375 371 write (*,*) ' Below-cloud scavenging: ON' … … 381 377 382 378 ! NIK 31.01.2013 + 10.12.2013 + 15.02.2015 383 if (dquer(i).gt.0. .and.(ccn_aero(i).gt.0. .or. in_aero(i).gt.0.)) then384 WETDEP=.true.385 WETDEPSPEC(i)=.true.379 if (dquer(i).gt.0. .and. (ccn_aero(i).gt.0. .or. in_aero(i).gt.0.)) then 380 wetdep = .true. 381 wetdepspec(i) = .true. 386 382 if (lroot) then 387 383 write (*,*) ' In-cloud scavenging: ON' … … 394 390 395 391 if (ohcconst(i).gt.0.) then 396 OHREA=.true.392 ohrea = .true. 397 393 if (lroot) write (*,*) ' OHreaction switched on: ',ohcconst(i),i 398 394 endif 399 395 400 if ( (reldiff(i).gt.0.).or.(density(i).gt.0.).or.(dryvel(i).gt.0.)) then401 DRYDEP=.true.402 DRYDEPSPEC(i)=.true.396 if (reldiff(i).gt.0. .or. density(i).gt.0. .or. dryvel(i).gt.0.) then 397 drydep = .true. 398 drydepspec(i) = .true. 403 399 endif 404 400 … … 415 411 101 numpoint=numpoint+1 416 412 417 if ( readerror.lt.1) then ! reading namelist format413 if (ios.lt.1) then ! reading namelist format 418 414 419 415 if (numpoint.gt.numpoints) goto 250 420 zkind= 1421 mass = 0422 parts = 0416 ikindz = 1 417 rmass = -1. ! initialise as negative to catch if not given in input 418 nparts = 0 423 419 comment = ' ' 424 read(unitreleases,release,iostat= readerror)420 read(unitreleases,release,iostat=ios) 425 421 id1=idate1 426 422 it1=itime1 427 423 id2=idate2 428 424 it2=itime2 429 xpoint1(numpoint)= lon1430 xpoint2(numpoint)= lon2431 ypoint1(numpoint)= lat1432 ypoint2(numpoint)= lat2425 xpoint1(numpoint)=rlon1 426 xpoint2(numpoint)=rlon2 427 ypoint1(numpoint)=rlat1 428 ypoint2(numpoint)=rlat2 433 429 zpoint1(numpoint)=z1 434 430 zpoint2(numpoint)=z2 435 kindz(numpoint)= zkind431 kindz(numpoint)=ikindz 436 432 do i=1,nspec 437 xmass(numpoint,i)=mass(i) 433 if (rmass(i) .lt. 0.) goto 995 ! write error and stop 434 xmass(numpoint,i)=rmass(i) 438 435 end do 439 npart(numpoint)= parts436 npart(numpoint)=nparts 440 437 compoint(min(1001,numpoint))=comment 441 438 … … 445 442 endif 446 443 447 else 444 else ! simple text format 448 445 449 446 read(unitreleases,*,end=250) … … 471 468 read(unitreleases,*,err=998) xmass(numpoint,i) 472 469 if (old) call skplin(2,unitreleases) 473 mass(i)=xmass(numpoint,i)470 rmass(i)=xmass(numpoint,i) 474 471 end do 475 472 !save compoint only for the first 1000 release points … … 489 486 idate2=id2 490 487 itime2=it2 491 lon1=xpoint1(numpoint)492 lon2=xpoint2(numpoint)493 lat1=ypoint1(numpoint)494 lat2=ypoint2(numpoint)488 rlon1=xpoint1(numpoint) 489 rlon2=xpoint2(numpoint) 490 rlat1=ypoint1(numpoint) 491 rlat2=ypoint2(numpoint) 495 492 z1=zpoint1(numpoint) 496 493 z2=zpoint2(numpoint) 497 zkind=kindz(numpoint)498 parts=npart(numpoint)494 ikindz=kindz(numpoint) 495 nparts=npart(numpoint) 499 496 write(unitreleasesout,nml=release) 500 497 endif 501 498 502 499 if (numpoint.le.1000) then 503 if ((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. &504 (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.).and. &505 (compoint(numpoint)(1:8).eq.' ')) goto 250500 if (xpoint1(numpoint).eq.0. .and. ypoint1(numpoint).eq.0. .and. & 501 xpoint2(numpoint).eq.0. .and. ypoint2(numpoint).eq.0. .and. & 502 compoint(numpoint)(1:8).eq.' ') goto 250 506 503 else 507 if ((xpoint1(numpoint).eq.0.).and.(ypoint1(numpoint).eq.0.).and. &508 (xpoint2(numpoint).eq.0.).and.(ypoint2(numpoint).eq.0.)) goto 250504 if (xpoint1(numpoint).eq.0. .and. ypoint1(numpoint).eq.0. .and. & 505 xpoint2(numpoint).eq.0. .and. ypoint2(numpoint).eq.0.) goto 250 509 506 endif 510 507 … … 539 536 !********************************************************************* 540 537 541 if (xpoint1(numpoint) .lt.xlon0) &542 xpoint1(numpoint)=xpoint1(numpoint)+360.543 if (xpoint1(numpoint) .gt.xlon0+(nxmin1)*dx) &544 xpoint1(numpoint)=xpoint1(numpoint)-360.545 if (xpoint2(numpoint) .lt.xlon0) &546 xpoint2(numpoint)=xpoint2(numpoint)+360.547 if (xpoint2(numpoint) .gt.xlon0+(nxmin1)*dx) &548 xpoint2(numpoint)=xpoint2(numpoint)-360.538 if (xpoint1(numpoint) .lt. xlon0) & 539 xpoint1(numpoint) = xpoint1(numpoint) + 360. 540 if (xpoint1(numpoint) .gt. xlon0+nxmin1*dx) & 541 xpoint1(numpoint) = xpoint1(numpoint) - 360. 542 if (xpoint2(numpoint) .lt. xlon0) & 543 xpoint2(numpoint) = xpoint2(numpoint) + 360. 544 if (xpoint2(numpoint) .gt. xlon0+nxmin1*dx) & 545 xpoint2(numpoint) = xpoint2(numpoint) - 360. 549 546 550 547 ! Determine relative beginning and ending times of particle release … … 562 559 if (mdomainfill.eq.0) then ! no domain filling 563 560 if (ldirect.eq.1) then 564 if ( (jul1.lt.bdate).or.(jul2.gt.edate)) then561 if (jul1.lt.bdate .or. jul2.gt.edate) then 565 562 write(*,*) 'FLEXPART MODEL ERROR' 566 563 write(*,*) 'Release starts before simulation begins or ends' … … 577 574 endif 578 575 else if (ldirect.eq.-1) then 579 if ( (jul1.lt.edate).or.(jul2.gt.bdate)) then576 if (jul1.lt.edate .or. jul2.gt.bdate) then 580 577 write(*,*) 'FLEXPART MODEL ERROR' 581 578 write(*,*) 'Release starts before simulation begins or ends' … … 586 583 if (npart(numpoint).gt.num_min_discrete) then 587 584 ireleasestart(numpoint)=int((jul1-bdate)*86400.) 588 ireleaseend(numpoint) =int((jul2-bdate)*86400.)585 ireleaseend(numpoint) = int((jul2-bdate)*86400.) 589 586 else 590 587 ireleasestart(numpoint)=int((julm-bdate)*86400.) 591 ireleaseend(numpoint) =int((julm-bdate)*86400.)588 ireleaseend(numpoint) = int((julm-bdate)*86400.) 592 589 endif 593 590 endif … … 600 597 601 598 if (ireleasestart(numpoint).ne.ireleaseend(numpoint)) then 602 releaserate =releaserate+real(npart(numpoint))/ &603 real(ireleaseend(numpoint)-ireleasestart(numpoint))599 releaserate = releaserate + real( npart(numpoint) ) / & 600 real( ireleaseend(numpoint) - ireleasestart(numpoint) ) 604 601 else 605 602 releaserate=99999999 … … 634 631 nsettle=0 635 632 do ispc=1,nspec 636 if (xmass(irel,ispc).gt. eps2) nsettle=nsettle+1633 if (xmass(irel,ispc).gt.tiny(1.)) nsettle=nsettle+1 637 634 end do 638 635 if (nsettle.gt.1) lsettling=.false. … … 641 638 642 639 if (lroot) then 643 if (.not.lsettling) then 644 write(*,*) 'WARNING: more than 1 species per release point, settling & 645 &disabled' 646 end if 640 if (.not.lsettling) & 641 write(*,*) 'WARNING: more than 1 species per release point,' & 642 // ' settling disabled' 647 643 end if 648 644 … … 651 647 !************************************************************************ 652 648 653 if (releaserate.gt. & 654 0.99*real(maxpart)/real(lage(nageclass))) then 649 if (releaserate .gt. 0.99*real(maxpart)/real(lage(nageclass))) then 655 650 if (numpartmax.gt.maxpart.and.lroot) then 656 651 write(*,*) '#####################################################' … … 670 665 write(*,*) 'Maximum allowed release rate is: ', & 671 666 real(maxpart)/real(lage(nageclass)),' particles per second' 672 write(*,*) & 673 'Total number of particles released during the simulation is: ', & 674 numpartmax 667 write(*,*) 'Total number of particles released during the simulation is:'& 668 ,numpartmax 675 669 write(*,*) 'Maximum allowed number of particles is: ',maxpart 676 670 endif … … 679 673 680 674 if (lroot) then 681 write(*,FMT='(A,ES14.7)') ' Total mass released:', sum(xmass(1:numpoint,1:nspec)) 675 write(*,FMT='(A,ES14.7)') ' Total mass released:', & 676 sum(xmass(1:numpoint,1:nspec)) 682 677 end if 683 678 684 679 return 685 680 686 99 4write(*,*) '#####################################################'681 995 write(*,*) '#####################################################' 687 682 write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' 688 683 write(*,*) '#### ####' 689 write(*,*) '#### ERROR - MAXIMUM NUMBER OF EMITTED SPECIES IS####' 690 write(*,*) '#### TOO LARGE. PLEASE REDUCE NUMBER OF SPECIES. ####' 684 write(*,*) '#### ERROR - mass for species',i,' not given ####' 691 685 write(*,*) '#####################################################' 686 stop 'readreleases - undefined mass' 687 688 994 write(*,*) '######################################################' 689 write(*,*) '#### FLEXPART MODEL SUBROUTINE READRELEASES: ####' 690 write(*,*) '#### ####' 691 write(*,*) '#### ERROR - MAXIMUM NUMBER OF EMITTED SPECIES IS ####' 692 write(*,*) '#### TOO LARGE. PLEASE REDUCE NUMBER OF SPECIES. ####' 693 write(*,*) '######################################################' 692 694 stop 693 695 … … 702 704 stop 703 705 704 705 706 999 write(*,*) '#####################################################' 706 707 write(*,*) ' FLEXPART MODEL SUBROUTINE READRELEASES: ' … … 713 714 714 715 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "RELEASES" #### ' 715 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY#### '716 write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' 716 717 write(*,'(a)') path(2)(1:length(2)) 717 718 stop -
src/timemanager.f90
rc0884a8 rd7935de 719 719 ! Output to keep track of the numerical instabilities in CBL simulation and if 720 720 ! they are compromising the final result (or not) 721 if ( cblflag.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl721 if (iflagcbl.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 722 722 723 723 end do -
src/timemanager_mpi.f90
rc0884a8 rd7935de 876 876 ! Output to keep track of the numerical instabilities in CBL simulation 877 877 ! and if they are compromising the final result (or not): 878 if ( cblflag.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl878 if (iflagcbl.eq.1) print *,j,itime,'nan_synctime',nan_count,'nan_tl',total_nan_intl 879 879 880 880
Note: See TracChangeset
for help on using the changeset viewer.