Changeset b4d29ce in flexpart.git for src/readoutgrid.f90


Ignore:
Timestamp:
Jul 3, 2014, 2:55:50 PM (10 years ago)
Author:
Harald Sodemann <harald.sodemann@…>
Branches:
master, 10.4.1_pesei, FPv9.3.1, FPv9.3.1b_testing, FPv9.3.2, GFS_025, NetCDF, bugfixes+enhancements, deposition, dev, fp9.3.1-20161214-nc4, grib2nc4_repair, inputlist, laptop, release-10, release-10.4.1, scaling-bug, svn-petra, svn-trunk, univie
Children:
4b093cc, 75dfd42, 326b31b
Parents:
87910af
Message:
  • Implemented optional namelist input for COMMAND, RELEASES, SPECIES, AGECLASSES,OUTGRID,OUTGRID_NEST,RECEPTORS
  • Implemented com_mod switch nmlout to write input files as namelist to the output directory (.true. by default)
  • Proposed updated startup and runtime output (may change back to previous info if desired)

git-svn-id: http://flexpart.flexpart.eu:8088/svn/FlexPart90/trunk@27 ef8cc7e1-21b7-489e-abab-c1baa636049d

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/readoutgrid.f90

    rf13406c rb4d29ce  
    2929  !                                                                            *
    3030  !     4 June 1996                                                            *
     31  !     HSO, 1 July 2014
     32  !     Added optional namelist input
    3133  !                                                                            *
    3234  !*****************************************************************************
     
    5355  real,parameter :: eps=1.e-4
    5456
    55 
     57  ! namelist variables
     58  integer, parameter :: maxoutlev=500
     59  integer :: readerror
     60  real,allocatable, dimension (:) :: outheights
     61
     62  ! declare namelist
     63  namelist /outgrid/ &
     64    outlon0,outlat0, &
     65    numxgrid,numygrid, &
     66    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
    5676
    5777  ! Open the OUTGRID file and read output grid specifications
    5878  !**********************************************************
    5979
    60   open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old', &
    61        err=999)
    62 
    63 
    64   call skplin(5,unitoutgrid)
    65 
    66 
    67   ! 1.  Read horizontal grid specifications
    68   !****************************************
    69 
    70   call skplin(3,unitoutgrid)
    71   read(unitoutgrid,'(4x,f11.4)') outlon0
    72   call skplin(3,unitoutgrid)
    73   read(unitoutgrid,'(4x,f11.4)') outlat0
    74   call skplin(3,unitoutgrid)
    75   read(unitoutgrid,'(4x,i5)') numxgrid
    76   call skplin(3,unitoutgrid)
    77   read(unitoutgrid,'(4x,i5)') numygrid
    78   call skplin(3,unitoutgrid)
    79   read(unitoutgrid,'(4x,f12.5)') dxout
    80   call skplin(3,unitoutgrid)
    81   read(unitoutgrid,'(4x,f12.5)') dyout
    82 
     80  open(unitoutgrid,file=path(1)(1:length(1))//'OUTGRID',status='old',form='formatted',err=999)
     81
     82  ! try namelist input
     83  read(unitoutgrid,outgrid,iostat=readerror)
     84  close(unitoutgrid)
     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
     92    call skplin(5,unitoutgrid)
     93
     94    ! 1.  Read horizontal grid specifications
     95    !****************************************
     96
     97    call skplin(3,unitoutgrid)
     98    read(unitoutgrid,'(4x,f11.4)') outlon0
     99    call skplin(3,unitoutgrid)
     100    read(unitoutgrid,'(4x,f11.4)') outlat0
     101    call skplin(3,unitoutgrid)
     102    read(unitoutgrid,'(4x,i5)') numxgrid
     103    call skplin(3,unitoutgrid)
     104    read(unitoutgrid,'(4x,i5)') numygrid
     105    call skplin(3,unitoutgrid)
     106    read(unitoutgrid,'(4x,f12.5)') dxout
     107    call skplin(3,unitoutgrid)
     108    read(unitoutgrid,'(4x,f12.5)') dyout
     109
     110  endif
    83111
    84112  ! Check validity of output grid (shall be within model domain)
     
    91119  if ((outlon0+eps.lt.xlon0).or.(outlat0+eps.lt.ylat0) &
    92120       .or.(xr.gt.xr1+eps).or.(yr.gt.yr1+eps)) then
    93     write(*,*) 'outlon0,outlat0:'
    94121    write(*,*) outlon0,outlat0
    95     write(*,*) 'xr1,yr1,xlon0,ylat0,xr,yr,dxout,dyout:'
    96122    write(*,*) xr1,yr1,xlon0,ylat0,xr,yr,dxout,dyout
    97123    write(*,*) ' #### FLEXPART MODEL ERROR! PART OF OUTPUT    ####'
     
    104130  ! 2. Count Vertical levels of output grid
    105131  !****************************************
    106   j=0
    107 100   j=j+1
     132
     133  if (readerror.ne.0) then
     134    j=0
     135100 j=j+1
    108136    do i=1,3
    109137      read(unitoutgrid,*,end=99)
     
    112140    if (outhelp.eq.0.) goto 99
    113141    goto 100
    114 99   numzgrid=j-1
    115 
    116     allocate(outheight(numzgrid) &
    117          ,stat=stat)
    118     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    119     allocate(outheighthalf(numzgrid) &
    120          ,stat=stat)
    121     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    122 
    123 
    124   rewind(unitoutgrid)
    125   call skplin(29,unitoutgrid)
     14299  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'
    126154
    127155  ! 2. Vertical levels of output grid
    128156  !**********************************
    129157
    130   j=0
    131 1000   j=j+1
    132     do i=1,3
    133       read(unitoutgrid,*,end=990)
    134     end do
    135     read(unitoutgrid,'(4x,f7.1)',end=990) outhelp
    136     if (outhelp.eq.0.) goto 99
    137     outheight(j)=outhelp
    138     goto 1000
    139 990   numzgrid=j-1
    140 
     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
     179  endif
     180
     181  ! write outgrid file in namelist format to output directory if requested
     182  if (nmlout.eqv..true.) 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)
     194    close(unitoutgrid)
     195  endif
    141196
    142197  ! Check whether vertical levels are specified in ascending order
     
    160215  end do
    161216
    162 
    163217  xoutshift=xlon0-outlon0
    164218  youtshift=ylat0-outlat0
    165   close(unitoutgrid)
    166 
    167     allocate(oroout(0:numxgrid-1,0:numygrid-1) &
    168          ,stat=stat)
    169     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    170     allocate(area(0:numxgrid-1,0:numygrid-1) &
    171          ,stat=stat)
    172     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    173     allocate(volume(0:numxgrid-1,0:numygrid-1,numzgrid) &
    174          ,stat=stat)
    175     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    176     allocate(areaeast(0:numxgrid-1,0:numygrid-1,numzgrid) &
    177          ,stat=stat)
    178     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
    179     allocate(areanorth(0:numxgrid-1,0:numygrid-1,numzgrid) &
    180          ,stat=stat)
    181     if (stat.ne.0) write(*,*)'ERROR: could not allocate outh'
     219
     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'
    182230  return
    183231
    184232
    185 999   write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
     233999 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
    186234  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
    187   write(*,*) ' #### xxx/flexpart/options                    #### '
     235  write(*,'(a)') path(1)(1:length(1))
    188236  stop
    189237
     2381000 write(*,*) ' #### FLEXPART MODEL ERROR! FILE "OUTGRID"    #### '
     239  write(*,*) ' #### CANNOT BE OPENED IN THE DIRECTORY       #### '
     240  write(*,'(a)') path(2)(1:length(2))
     241  stop
     242
    190243end subroutine readoutgrid
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG