[e200b7a] | 1 | !********************************************************************** |
---|
| 2 | ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 * |
---|
| 3 | ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, * |
---|
| 4 | ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
| 5 | ! * |
---|
| 6 | ! This file is part of FLEXPART. * |
---|
| 7 | ! * |
---|
| 8 | ! FLEXPART is free software: you can redistribute it and/or modify * |
---|
| 9 | ! it under the terms of the GNU General Public License as published by* |
---|
| 10 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
| 11 | ! (at your option) any later version. * |
---|
| 12 | ! * |
---|
| 13 | ! FLEXPART is distributed in the hope that it will be useful, * |
---|
| 14 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | ! GNU General Public License for more details. * |
---|
| 17 | ! * |
---|
| 18 | ! You should have received a copy of the GNU General Public License * |
---|
| 19 | ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
| 20 | !********************************************************************** |
---|
| 21 | |
---|
| 22 | subroutine readageclasses |
---|
| 23 | |
---|
| 24 | !***************************************************************************** |
---|
| 25 | ! * |
---|
| 26 | ! This routine reads the age classes to be used for the current model * |
---|
| 27 | ! run. * |
---|
| 28 | ! * |
---|
| 29 | ! Author: A. Stohl * |
---|
| 30 | ! 20 March 2000 * |
---|
[b4d29ce] | 31 | ! HSO, 1 July 2014 * |
---|
| 32 | ! Added optional namelist input * |
---|
[e200b7a] | 33 | ! * |
---|
| 34 | !***************************************************************************** |
---|
| 35 | ! * |
---|
| 36 | ! Variables: * |
---|
| 37 | ! * |
---|
| 38 | ! Constants: * |
---|
| 39 | ! * |
---|
| 40 | !***************************************************************************** |
---|
| 41 | |
---|
| 42 | use par_mod |
---|
| 43 | use com_mod |
---|
| 44 | |
---|
| 45 | implicit none |
---|
| 46 | |
---|
| 47 | integer :: i |
---|
| 48 | |
---|
[b4d29ce] | 49 | ! namelist help variables |
---|
| 50 | integer :: readerror |
---|
| 51 | |
---|
| 52 | ! namelist declaration |
---|
| 53 | namelist /ageclass/ & |
---|
| 54 | nageclass, & |
---|
| 55 | lage |
---|
| 56 | |
---|
| 57 | nageclass=-1 ! preset to negative value to identify failed namelist input |
---|
[e200b7a] | 58 | |
---|
| 59 | ! If age spectra calculation is switched off, set number of age classes |
---|
| 60 | ! to 1 and maximum age to a large number |
---|
| 61 | !********************************************************************** |
---|
| 62 | |
---|
| 63 | if (lagespectra.ne.1) then |
---|
| 64 | nageclass=1 |
---|
| 65 | lage(nageclass)=999999999 |
---|
| 66 | return |
---|
| 67 | endif |
---|
| 68 | |
---|
| 69 | ! If age spectra claculation is switched on, |
---|
| 70 | ! open the AGECLASSSES file and read user options |
---|
| 71 | !************************************************ |
---|
| 72 | |
---|
[b4d29ce] | 73 | open(unitageclasses,file=path(1)(1:length(1))//'AGECLASSES',form='formatted',status='old',err=999) |
---|
| 74 | |
---|
| 75 | ! try to read in as a namelist |
---|
| 76 | read(unitageclasses,ageclass,iostat=readerror) |
---|
| 77 | close(unitageclasses) |
---|
| 78 | |
---|
| 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) |
---|
| 88 | end do |
---|
| 89 | close(unitageclasses) |
---|
| 90 | endif |
---|
[e200b7a] | 91 | |
---|
[b4d29ce] | 92 | ! write ageclasses file in namelist format to output directory if requested |
---|
| 93 | if (nmlout.eqv..true.) then |
---|
| 94 | open(unitageclasses,file=path(2)(1:length(2))//'AGECLASSES.namelist',err=1000) |
---|
| 95 | write(unitageclasses,nml=ageclass) |
---|
| 96 | close(unitageclasses) |
---|
| 97 | endif |
---|
[e200b7a] | 98 | |
---|
| 99 | if (nageclass.gt.maxageclass) then |
---|
| 100 | 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 | stop |
---|
| 106 | endif |
---|
| 107 | |
---|
| 108 | if (lage(1).le.0) then |
---|
| 109 | write(*,*) ' #### FLEXPART MODEL ERROR! AGE OF FIRST #### ' |
---|
| 110 | write(*,*) ' #### CLASS MUST BE GREATER THAN ZERO. CHANGE #### ' |
---|
| 111 | write(*,*) ' #### SETTINGS IN FILE AGECLASSES. #### ' |
---|
| 112 | stop |
---|
| 113 | endif |
---|
| 114 | |
---|
| 115 | do i=2,nageclass |
---|
| 116 | if (lage(i).le.lage(i-1)) then |
---|
| 117 | write(*,*) ' #### FLEXPART MODEL ERROR! AGE CLASSES #### ' |
---|
| 118 | write(*,*) ' #### MUST BE GIVEN IN TEMPORAL ORDER. #### ' |
---|
| 119 | write(*,*) ' #### CHANGE SETTINGS IN FILE AGECLASSES. #### ' |
---|
| 120 | stop |
---|
| 121 | endif |
---|
| 122 | end do |
---|
| 123 | |
---|
| 124 | return |
---|
| 125 | |
---|
| 126 | 999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "AGECLASSES" #### ' |
---|
| 127 | write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' |
---|
| 128 | write(*,'(a)') path(1)(1:length(1)) |
---|
| 129 | stop |
---|
| 130 | |
---|
[b4d29ce] | 131 | 1000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "AGECLASSES" #### ' |
---|
| 132 | write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY #### ' |
---|
| 133 | write(*,'(a)') path(2)(1:length(2)) |
---|
| 134 | stop |
---|
| 135 | |
---|
| 136 | |
---|
[e200b7a] | 137 | end subroutine readageclasses |
---|