[2eefa58] | 1 | subroutine initial_cond_output_inversion(itime) |
---|
| 2 | ! i |
---|
| 3 | !***************************************************************************** |
---|
| 4 | ! * |
---|
| 5 | ! Output of the initial condition sensitivity field. * |
---|
| 6 | ! * |
---|
| 7 | ! Author: A. Stohl * |
---|
| 8 | ! * |
---|
| 9 | ! 24 May 1995 * |
---|
| 10 | ! * |
---|
| 11 | ! 13 April 1999, Major update: if output size is smaller, dump output * |
---|
| 12 | ! in sparse matrix format; additional output of * |
---|
| 13 | ! uncertainty * |
---|
| 14 | ! * |
---|
| 15 | ! 05 April 2000, Major update: output of age classes; output for backward* |
---|
| 16 | ! runs is time spent in grid cell times total mass of * |
---|
| 17 | ! species. * |
---|
| 18 | ! * |
---|
| 19 | ! 17 February 2002, Appropriate dimensions for backward and forward runs * |
---|
| 20 | ! are now specified in file par_mod * |
---|
| 21 | ! * |
---|
| 22 | ! June 2006, write grid in sparse matrix with a single write command * |
---|
| 23 | ! in order to save disk space * |
---|
| 24 | ! * |
---|
| 25 | ! 2008 new sparse matrix format * |
---|
| 26 | ! * |
---|
| 27 | !***************************************************************************** |
---|
| 28 | ! * |
---|
| 29 | ! Variables: * |
---|
| 30 | ! ncells number of cells with non-zero concentrations * |
---|
| 31 | ! sparse .true. if in sparse matrix format, else .false. * |
---|
| 32 | ! * |
---|
| 33 | !***************************************************************************** |
---|
| 34 | |
---|
| 35 | use unc_mod |
---|
| 36 | use point_mod |
---|
| 37 | use outg_mod |
---|
| 38 | use par_mod |
---|
| 39 | use com_mod |
---|
| 40 | |
---|
| 41 | implicit none |
---|
| 42 | |
---|
| 43 | integer :: itime,i,ix,jy,kz,ks,kp,sp_count_i,sp_count_r |
---|
| 44 | integer :: jjjjmmdd, ihmmss |
---|
| 45 | real(kind=dp) :: jul |
---|
| 46 | real :: sp_fact,fact_recept |
---|
| 47 | real,parameter :: smallnum = tiny(0.0) ! smallest number that can be handled |
---|
| 48 | logical :: sp_zer,lexist |
---|
| 49 | logical,save :: listart=.true. |
---|
| 50 | logical,save,allocatable,dimension(:) :: listartrel |
---|
| 51 | character :: adate*8,atime*6 |
---|
| 52 | character :: areldate*8,areltime*6 |
---|
| 53 | character(len=3) :: anspec |
---|
| 54 | |
---|
| 55 | if(listart) then |
---|
| 56 | allocate(listartrel(maxpointspec_act)) |
---|
| 57 | listartrel(:)=.true. |
---|
| 58 | endif |
---|
| 59 | print*, 'listartrel = ',listartrel |
---|
| 60 | |
---|
| 61 | !********************************************************************* |
---|
| 62 | ! Determine the standard deviation of the mean concentration or mixing |
---|
| 63 | ! ratio (uncertainty of the output) and the dry and wet deposition |
---|
| 64 | !********************************************************************* |
---|
| 65 | |
---|
| 66 | do ks=1,nspec |
---|
| 67 | |
---|
| 68 | write(anspec,'(i3.3)') ks |
---|
| 69 | |
---|
| 70 | do kp=1,maxpointspec_act |
---|
| 71 | |
---|
| 72 | ! calculate date of release |
---|
| 73 | jul=bdate+real(ireleasestart(kp),kind=dp)/86400._dp ! this is the current day |
---|
| 74 | call caldate(jul,jjjjmmdd,ihmmss) |
---|
| 75 | write(areldate,'(i8.8)') jjjjmmdd |
---|
| 76 | write(areltime,'(i6.6)') ihmmss |
---|
| 77 | print*, areldate//areltime |
---|
| 78 | |
---|
| 79 | ! calculate date of field |
---|
| 80 | jul=bdate+real(itime,kind=dp)/86400._dp |
---|
| 81 | call caldate(jul,jjjjmmdd,ihmmss) |
---|
| 82 | write(adate,'(i8.8)') jjjjmmdd |
---|
| 83 | write(atime,'(i6.6)') ihmmss |
---|
| 84 | print*, adate//atime |
---|
| 85 | |
---|
| 86 | inquire(file=path(2)(1:length(2))//'grid_initial_'//areldate// & |
---|
| 87 | areltime//'_'//anspec,exist=lexist) |
---|
| 88 | if(lexist.and..not.listartrel(kp)) then |
---|
| 89 | ! open and append to existing file |
---|
| 90 | open(97,file=path(2)(1:length(2))//'grid_initial_'//areldate// & |
---|
| 91 | areltime//'_'//anspec,form='unformatted',status='old',action='write',access='append') |
---|
| 92 | else |
---|
| 93 | ! open new file |
---|
| 94 | open(97,file=path(2)(1:length(2))//'grid_initial_'//areldate// & |
---|
| 95 | areltime//'_'//anspec,form='unformatted',status='replace',action='write') |
---|
| 96 | endif |
---|
| 97 | write(97) jjjjmmdd |
---|
| 98 | write(97) ihmmss |
---|
| 99 | |
---|
| 100 | listartrel(kp)=.false. |
---|
| 101 | |
---|
| 102 | if (ind_rel.eq.1) then |
---|
| 103 | fact_recept=rho_rel(kp) |
---|
| 104 | else |
---|
| 105 | fact_recept=1. |
---|
| 106 | endif |
---|
| 107 | |
---|
| 108 | !******************************************************************* |
---|
| 109 | ! Generate output: may be in concentration (ng/m3) or in mixing |
---|
| 110 | ! ratio (ppt) or both |
---|
| 111 | ! Output the position and the values alternated multiplied by |
---|
| 112 | ! 1 or -1, first line is number of values, number of positions |
---|
| 113 | ! For backward simulations, the unit is seconds, stored in grid_time |
---|
| 114 | !******************************************************************* |
---|
| 115 | |
---|
| 116 | ! Write out dummy "wet and dry deposition" fields, to keep same format |
---|
| 117 | ! as for concentration output |
---|
| 118 | ! sp_count_i=0 |
---|
| 119 | ! sp_count_r=0 |
---|
| 120 | ! write(97) sp_count_i |
---|
| 121 | ! write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
| 122 | ! write(97) sp_count_r |
---|
| 123 | ! write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
| 124 | ! write(97) sp_count_i |
---|
| 125 | ! write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
| 126 | ! write(97) sp_count_r |
---|
| 127 | ! write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | ! Write out sensitivity to initial conditions |
---|
| 131 | sp_count_i=0 |
---|
| 132 | sp_count_r=0 |
---|
| 133 | sp_fact=-1. |
---|
| 134 | sp_zer=.true. |
---|
| 135 | do kz=1,numzgrid |
---|
| 136 | do jy=0,numygrid-1 |
---|
| 137 | do ix=0,numxgrid-1 |
---|
| 138 | if (init_cond(ix,jy,kz,ks,kp).gt.smallnum) then |
---|
| 139 | if (sp_zer.eqv..true.) then ! first non zero value |
---|
| 140 | sp_count_i=sp_count_i+1 |
---|
| 141 | sparse_dump_i(sp_count_i)= & |
---|
| 142 | ix+jy*numxgrid+kz*numxgrid*numygrid |
---|
| 143 | sp_zer=.false. |
---|
| 144 | sp_fact=sp_fact*(-1.) |
---|
| 145 | endif |
---|
| 146 | sp_count_r=sp_count_r+1 |
---|
| 147 | sparse_dump_r(sp_count_r)=sp_fact* & |
---|
| 148 | init_cond(ix,jy,kz,ks,kp)/xmass(kp,ks)*fact_recept |
---|
| 149 | else ! concentration is zero |
---|
| 150 | sp_zer=.true. |
---|
| 151 | endif |
---|
| 152 | end do |
---|
| 153 | end do |
---|
| 154 | end do |
---|
| 155 | write(97) sp_count_i |
---|
| 156 | write(97) (sparse_dump_i(i),i=1,sp_count_i) |
---|
| 157 | write(97) sp_count_r |
---|
| 158 | write(97) (sparse_dump_r(i),i=1,sp_count_r) |
---|
| 159 | |
---|
| 160 | close(97) |
---|
| 161 | |
---|
| 162 | end do |
---|
| 163 | |
---|
| 164 | end do |
---|
| 165 | |
---|
| 166 | ! reset listart |
---|
| 167 | if (listart) then |
---|
| 168 | listart=.false. |
---|
| 169 | endif |
---|
| 170 | |
---|
| 171 | end subroutine initial_cond_output_inversion |
---|