Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Problems with ps_rand_local in the Bgrid Model #354

@mgharamti

Description

@mgharamti

Describe the bug

While trying to run the bgrid_solo model, I ran into a number of issues. These issues are mainly related to the observation preparation step. I'm using models/bgrid_solo/ps_rand_local.f90 routine to generate an input file named ps_rand.out that can then be fed to create_obs_sequence. In order to run ps_rand_local, I run the following command:

./ps_rand_local < ps_rand.input

ps_rand.input is a file I prepared ahead of time which includes answers to questions asked by ps_rand_local. The contents of ps_rand.input are as follows:

3
100
-90
90
0
360

Here, 3 is the number of observations and 100 is the observation error variance. The remaining input parameters are self-explanatory. The first error message I get from ps_rand_local is the following:

 FATAL ERROR in get_unit
    initialize_utilities() or initialize_mpi_utilities()
    must be called before calling get_unit().
   utilities_mod.f90
    stopping.

To bypass this, I added this call initialize_utilities('ps_rand_local') right before the call for get_unit (So, one also needs to add initialize_utilities in the modules to use from utilities_mod towards the top of the file). This fixes this issue. Once the routine finishes running, it writes out ps_rand.out which should look like this:

           3   
           0   
           0   
           0   
 RADIOSONDE_SURFACE_PRESSURE
          -1  
          -1  
          -1  
   0.0000000000000000    
   360.00000000000000    
  -90.000000000000000    
   90.000000000000000    
           0           0   
   100.00000000000000    
           0   
 RADIOSONDE_SURFACE_PRESSURE
          -1  
          -1  
          -1  
   0.0000000000000000    
   360.00000000000000    
  -90.000000000000000    
   90.000000000000000    
           0           0   
   100.00000000000000    
           0   
 RADIOSONDE_SURFACE_PRESSURE
          -1  
          -1  
          -1  
   0.0000000000000000    
   360.00000000000000    
  -90.000000000000000    
   90.000000000000000    
           0           0   
   100.00000000000000    
 set_def.out

Next, I run create_obs_sequence in order to create an obs sequence template using this command:

./create_obs_sequence < ps_rand.out

You will get complaints about the observation type being invalid and that's (I believe) because of the single space that precedes RADIOSONDE_SURFACE_PRESSURE. If you fix this, you'll see that the file that is written out is named " set_def.out" with a space at the beginning. This would cause an issue when trying to use that file for the create_fixed_network_seq routine. In addition, I got some problems with the variance (100) being interpreted inside set_def.out as sometimes 10000 and other time 1. All of this to say, ps_rand_local is writing stuff to file without proper formatting. Here is what the body of the file currently looks like:

! Input number of obs
write(iunit, *) num 
! No obs values or qc
write(iunit, *) 0
write(iunit, *) 0

num_done = 0 
do while(num_done < num)
   ! There are more obs
   write(iunit, *) 0

   ! Kind is ps
   write(iunit, *) 'RADIOSONDE_SURFACE_PRESSURE'

   ! Put this on model level -1
   write(iunit, *) VERTISSURFACE
   write(iunit, *) level

   ! Want randomly located in horizontal
   write(iunit, *) -1

   ! Input longitude and latitude bounds
   write(iunit, *) bot_lon
   write(iunit, *) top_lon
   write(iunit, *) bot_lat
   write(iunit, *) top_lat

   ! Time is 0 days and 0 seconds for create_obs_sequence base
   write(iunit, *) 0, 0

   ! Error variance
   write(iunit, *) err_var

   num_done = num_done + 1 

end do

! File name default is set_def.out
write(iunit, *) 'set_def.out'

and here is what I changed to make it work:

! Input number of obs
write(iunit, '(I5)') num 
! No obs values or qc
write(iunit, '(I1)') 0
write(iunit, '(I1)') 0

num_done = 0 
do while(num_done < num)
   ! There are more obs
   write(iunit, '(I1)') 0

   ! Kind is ps
   write(iunit, '(A)') 'RADIOSONDE_SURFACE_PRESSURE'

   ! Put this on model level -1
   write(iunit, '(I2)') VERTISSURFACE
   write(iunit, '(I2)') level

   ! Want randomly located in horizontal
   write(iunit, '(I2)') -1

   ! Input longitude and latitude bounds
   write(iunit, '(F6.1)') bot_lon
   write(iunit, '(F6.1)') top_lon
   write(iunit, '(F6.1)') bot_lat
   write(iunit, '(F6.1)') top_lat

   ! Time is 0 days and 0 seconds for create_obs_sequence base
   write(iunit, *) 0, 0

   ! Error variance
   write(iunit, '(F5.1)') err_var

   num_done = num_done + 1 

end do

! File name default is set_def.out
write(iunit, '(A)') 'set_def.out'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions