# HOW TO RUN THE BRAMS 5.5



After download, compile and install the model:



1. Install the data files:
   
   The BRAMS 5.5 needs some fixed files:
   
   a) Tables (some tables for parametrizations)
   
   ```bash
   cd bin
   wget http://ftp.cptec.inpe.br/pesquisa/bramsrd/BRAMS/files/tables_2118.tar.xz
   xz -d tables_2118.tar.xz
   tar -xvf tables_2118.tar
   
   ```
   
   b) Fixed  data (vegetation, NDVI, sst, topography, etc)
   
   ```bash
   wget http://ftp.cptec.inpe.br/pesquisa/bramsrd/BRAMS/files/datafix.tar
   tar -xvf datafix.tar
   cd datafix
   xz -d *.xz
   cd ..
   ```

2. Create some auxiliary directories for datain and dataout (to/from model):
   
   ```bash
   mkdir datain
   mkdir datain/GRADS
   mkdir datain/GFS
   mkdir datain/QUEIMA
   mkdir dataout
   mkdir dataout/ANL
   mkdir dataout/HIS
   mkdir dataout/IVAR
   mkdir dataout/IC
   mkdir dataout/LOG
   mkdir dataout/SFC
   mkdir datout/UMD
   mkdir dataout/POST
   ```
   
   

3. Datain Initial conditions (IC/CC):
   
   To obtain datain please see the [PRE-BRAMS install](http://ftp.cptec.inpe.br/pesquisa/bramsrd/BRAMS/docs/How_to_Install_and_Run_PRE-BRAMS_5.5.html). The data will be generate from GFS model and the IC/CC will de write in bin format (grads). Then the data must be moved to datain/GRADS (or the output from pre-brams set to that directory).

4. Geting the BRAMS Namelist (RAMSIN):
   
   wget http://ftp.cptec.inpe.br/pesquisa/bramsrd/BRAMS/files/RAMSIN_base.xz

5. Edit the RAMSIN acordingly your preferences:
   
   **a) Data, domain, grid position, resolution and delta:**
   
   ****<mark>Please, is important to know that the model does not implement grid nesting yet. You must only use one grid. </mark>
   
   Adjust the parameters (bellow) to your preferences:
   
   ```bash
   TIMEUNIT = 'h', ! 'h','m','s' - Time units of TIMMAX, TIMSTR
   
   TIMMAX = 24., !48., ! Final time of simulation
   
   IMONTH1 =02, ! Month
   IDATE1 =03, ! Day
   IYEAR1 =2021, ! Year
   ITIME1 = 0000, ! GMT of model TIME = 0.
   
   ! Grid specifications
   NNXP = 30, ! Number of x gridpoints
   NNYP = 30, ! Number of y gridpoints
   NNZP = 45, ! Number of z gridpoints
    ...
   DELTAX = 20000.,
   DELTAY = 20000., ! X and Y grid spacing [m]
   
   DELTAZ = 80., ! Z grid spacing (set to 0. to use ZZ)
   DZRAT = 1.08, ! Vertical grid stretch ratio
    ...
   
   DTLONG = 120., ! Coarse grid long timestep [~4 x DELTAX/1000]
    ...
   POLELAT = -22.6, ! Latitude of pole point
   POLELON = -45.2, ! Longitude of pole point
   CENTLAT = -22.6,
   CENTLON = -45.2,
   ```
   
   **b) Type and frequency of output:**
   
   ```bash
      IPOS     =  2,                ! 0-no files, 2-grads files, 1-hdf5(not available yet) 
      IOUTPUT  =  0,                ! 0-no files, 1-save ASCII, 2-save binary
      HFILOUT  = './HIS/hOPQUE',      ! History file prefix
      AFILOUT  = './ANL/OPQUE',       ! Analysis file prefix
      ...
      FRQANL   = 10800.,            ! Analysis file frequency in seconds
   ```
   
   > Use IPOS=2 and IOUTPUT = 0 for output in GRADS. In this case You don't need to postprocess with RAMSPOST code. 
   
   **c) Setup for INITIAL conditions (IC/CC):**
   
   The model can get IC/CC data right from GRADS files generated by PRE-BRAMS. IN this case You must set some parameter as show bellow.
   
   
   ```bash
    !-----------------------------------
    ! Makevfile information IC = Initial Conditions
    !-----------------------------------
   
    ICFILETYPE=4, !0- ISAN using dprep, 1- do ISAN using NCEP GFS GRIB2,
                      !2- ISAN using netCDF 4-Get from grads
   
    INITIAL_LATITUDE = -70., !Initial latitude for domain of model (-90 to 90)
   
    FINAL_LATITUDE  = 29., !Final latitude for domain of model(-90 to 90)
   
    INITIAL_LONGITUDE = 250., !Initial longitude for domain of model (0 to 360)
   
    FINAL_LONGITUDE = 358., !Final longitude for domain of model (0 to 360)
   
   
   ```
   
   > Adjust the initial and final latitude and longitude acordingly You generate data on pre-brams. For the domain of interest with some lateral boundaries.
   
   **d) Setup for the output **
   
   The postprocess phase of the model, when IPOS=2 is made during the run time of BRAMS. The set of variables to be write ans geographic information are set in RAMSIN. 
   
   
   
   ```bash
    $POST
       NVP = 40,
       VP ='topo',         
   	'land',        
   	'sea_press',    
   	'precip',    
   	'acccon',       
   	'tveg',       
   	't2mj',         
   	'le',           
   	'h',            
   	'rshort',       
   	'rlong',       
   	'albedt',       
   	'rlongup',      
   	'cape',         
   	'cine',         
   	'zi',           
   	'sst',          
   	'pwt',          
   	'slp_metar',    
   	'td2mj',        
   	'u10mj',        
   	'v10mj',        
   	'smoist',      
   	'tempc',        
   	'ue_avg',      
   	've_avg',      
   	'rh',          
   	'geo',         
   	'cloud',       
   	'omeg',        
   	'ndvi', 
   	'lai'       ,
   	'rv'        ,	       
   !fim variaveis scamtec
            'sfc_press' ,
            'albedt'    ,
            'tempk'     ,
            'cucldp'    ,
            'curtdp'    ,
            'cuthdp'    ,
   
       GPREFIX = './dataout/POST/brams',
       CSVFILE = './variables.csv',
       ANL2GRA = 'ONE',
   
       PROJ='YES',
       MEAN_TYPE ='BAV', 
       LATI = -90.,-90.,    -90., -90.,
       LATF = +90.,+90.,    +90., +90., 
       LONI = -180.,-180., -180.,-180.,
       LONF =  180.,180.,   180., 180.,
       
       
       ZLEVMAX = 32,32,32,32,
       
       IPRESSLEV = 1,
       INPLEVS = 19,
       IPLEVS = 1000, 925, 900, 850, 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100,
       ASCII_DATA ='NO',
       SITE_LAT =-10.76,
       SITE_LON =-62.36,
    $END
   ```
   
   Set the number of variables to output adjusting  NVP. The name of variables are defined in VP separated by commas. All the variables You can use ar describe in file variables.csv

6. Runing the model:
   
   The model must be run in 3 phases: MAKESFC, MAKEVFILE and INITIAL. The MAKESFC phase build the surface files, vegetantion, topography, etc setting it for user preferences (domain, resolution, etc). The MAKEVFILE phase get the data from IC/CC and interpolate they for model resolution and grid. The INITAIL makes the time integration of model and produces the output.
   
   For MAKESFC phase set RUNTYPE in RAMSIN:
   
   ```bash
   RUNTYPE  = 'MAKESFC',
   ```
   
   And than, run the model using mpirun bu with only one processor:
   
   ```bash
   /opt/apps/bin/mpirun -np 1 brams-5.5 -f RAMSIN
   ```
   
   For MAKEVFILE phase set RUNTYPE in RAMSIN:
   
   ```bash
   RUNTYPE  = 'MAKEVFILE',
   ```
   
   And than, run the model using mpirun bu with only one processor:
   
   ```bash
   /opt/apps/bin/mpirun -np 1 brams-5.5 -f RAMSIN
   ```
   
   For INITIAL phase set RUNTYPE in RAMSIN:
   
   ```bash
   RUNTYPE  = 'INITIAL',
   ```
   
   And than, run the model using mpirun bu with only one processor:
   
   ```bash
   /opt/apps/bin/mpirun -np 16 brams-5.5 -f RAMSIN
   ```
   
    The phase INITIAL can be run with N processors. The number max of processors depends of number of columns (NNXP x NNYP). The minimum of columns per processor must be 25.


