source: flexpart.git/flexpart_code/GRIB2FLEXPART.F90 @ 48a5c5c

FPv9.3.1FPv9.3.1b_testingFPv9.3.2fp9.3.1-20161214-nc4grib2nc4_repair
Last change on this file since 48a5c5c was 48a5c5c, checked in by Don Morton <Don.Morton@…>, 8 years ago

Added in AWST mods for extensionless FP filenames and
new CTBTO message for GRIB2FLEXPART

  • Property mode set to 100644
File size: 6.5 KB
Line 
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
22program grib2flexpart
23
24  !*****************************************************************************
25  !                                                                            *
26  !     This is the GRIB 2 FP conversion routine                               *
27  !                                                                            *
28  !     Author: M. Harustak                                                    *
29  !                                                                            *
30  !     05 October 2015                                                        *
31  !                                                                            *
32  !*****************************************************************************
33  !                                                                            *
34  ! Variables:                                                                 *
35  !                                                                            *
36  ! Constants:                                                                 *
37  !                                                                            *
38  !*****************************************************************************
39
40  use point_mod
41  use par_mod
42  use com_mod
43  use conv_mod
44
45  implicit none
46
47  integer :: metdata_format = unknown_metdata
48  integer :: itime, nstop1
49  integer :: i
50  character(len=256) :: arg
51  character(len=512) :: dumpPath
52  character(len=512) :: inputFileName
53  character(len=512) :: nestedFileName
54  character(len=32) :: lsubgridTXT
55  integer :: useAvailable = 0
56
57  ! Print the GPL License statement
58  !*******************************************************
59#if defined CTBTO
60  print*,'Welcome to GRIB2FLEXPART Version 1.0 CTBTO'
61#else
62  print*,'Welcome to GRIB2FLEXPART Version 1.0'
63#endif
64
65  print*,'FLEXPART is free software released under the GNU Genera'// &
66       'l Public License.'
67
68  ! no argument => error
69  if (( iargc().lt.2 ).or.( iargc().eq.3)) then
70    print *,' '
71    print *,'Usage in use-available mode: grib2flexpart useAvailable <output directory>'
72    print *,'Usage in command line mode: grib2flexpart forward|backward subgrid <output directory> <source file> [<source file>...]'
73    print *,' '
74    stop 'Error: Missing arguments'
75  elseif ( iargc().eq.2 ) then
76    call getarg(1,arg)
77    if ( arg.eq."useAvailable" ) then
78      print *,'Running in use-available mode'
79      useAvailable = 1
80    else
81      print *,' '
82      print *,'Usage in use-available mode: grib2flexpart useAvailable <output directory>'
83      print *,'Usage in command line mode: grib2flexpart forward|backward subgrid <output directory> &
84 <source file> [<source file>...]'
85      print *,' '
86      stop 'Error: Incorrect arguments'
87    endif
88  else
89    ! 2 and more arguments => ok, parse arguments
90    call getarg(1,arg)
91    if ( arg.eq."forward") then
92      ldirect = 1
93    else if ( arg.eq."backward") then
94      ldirect = -1
95    else
96      print *,' '
97      print *,'Usage in use-available mode: grib2flexpart useAvailable <output directory>'
98      print *,'Usage in command line mode: grib2flexpart forward|backward subgrid <output directory> &
99<source file> [<source file>...]'
100      print *,' '
101      stop 'Error: Incorrect arguments'
102    endif
103    print *,'Running in command line mode'
104    useAvailable = 0
105  endif
106
107  if ( useAvailable.eq.0 ) then
108    call getarg(2,lsubgridTxt)
109    read (lsubgridTxt, '(i10)') lsubgrid
110    lsubgrid=1
111    call getarg(3,dumpPath)
112    do i=4,iargc()
113      call getarg(i,inputFileName)
114      numbwf = i - 4 + 1
115      if ( ldirect.eq.1 ) then
116        wfname(i-4+1) = inputFileName
117      else
118        wfname(iargc()+1-i) = inputFileName
119      endif
120    end do
121
122  else
123    call getarg(2,dumpPath)
124
125    call readpaths
126
127    call readcommand
128
129    call readavailable
130  endif
131
132! Reset the times of the wind fields that are kept in memory to no time
133 !**********************************************************************
134
135  do i=1,2
136    memind(i)=i
137    memtime(i)=999999999
138  end do
139
140  ! Detect metdata format
141  call detectformat(metdata_format)
142  if (metdata_format.eq.ecmwf_metdata) then
143    print*,'ECMWF metdata detected'
144  elseif (metdata_format.eq.gfs_metdata) then
145    print*,'NCEP metdata detected'
146  else
147    stop 'Unknown metdata format'
148  endif
149
150  ! Read the model grid specifications,
151  ! both for the mother domain and eventual nests
152  !**********************************************
153
154  if (metdata_format.eq.ecmwf_metdata) call gridcheck_ecmwf
155  if (metdata_format.eq.gfs_metdata) call gridcheck_gfs
156  call gridcheck_nests
157
158  do i=1,numbwf
159    if ( ( useAvailable.eq.0 ).or.(numbwf.eq.1) ) then
160      print *,' '
161      print *,wfname(i)
162      call convertfields( i, metdata_format, dumpPath)
163    else
164       if (((ldirect*wftime(i).le.0).and. &
165             (ldirect*wftime(i+1).gt.0)).or. &
166          (ldirect*wftime(i).gt.0)) then
167          print *,' '
168          print *,wfname(i)
169          call convertfields( i, metdata_format, dumpPath)
170       endif
171    endif
172  end do
173
174  write(*,*) 'CONGRATULATIONS: YOU HAVE SUCCESSFULLY COMPLETED A GRIB2FLE&
175       &XPART PREPROCESSING RUN!'
176
177end program grib2flexpart
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG