[ncl-talk] Convective Temp Calculation

Brandon Sullivan btsullivan91 at gmail.com
Sun Apr 5 11:41:46 MDT 2015


Dennis and all... I have decided to take a different approach here.. As you
mentioned, the other code is very sloppy, and really I haven't been able to
get a good result with it.

I am trying a new method now. I will assume you are all familiar with
calculating convective temperature from a sounding. What I have done now is
taken a "top down" approach. I loop through and find where the saturation
mixing ratio (k) - mixing ratio (sfc) becomes greater than 0.. This is
effectively locating the CCL. From there I just use poisson's equation to
calculate the temperature that parcel would have at the surface, thus
calculating convective temperature.

This works pretty decent, except it's a few degrees off.. Given the data
may exist on x vertical levels, there is a high likelihood that the actual
CCL occurs between two points in the sounding. Thus my convective
temperature is a few degrees off, because it feels the height of the CCL is
different.

To solve this, I figure doing some sort of interpolation is the only
answer, but I have struggled to do this correctly.. I have tried ispan, and
wrf_interp_1d (those aren't in here now since it wasn't working) but I am
not sure how to do it correctly. I need to create a new pressure array to
interpolate to? I was trying to do something like ispan(101300,2000,100) to
get a new pressure array in 1mb increments or something. That was probably
too dramatic.

If this is the case, should I interpolate all my variables from the
beginning?

Thanks so much in advance.

Brandon Sullivan

On Wed, Mar 25, 2015 at 9:52 PM, Dennis Shea <shea at ucar.edu> wrote:

> I have looked. I do not see anything wrong.
>
> (1) The code *is* 'sloppy'.
>       Please note that the sstats.f is *not* NCL supported code.
>       A poster sent it to ncl-talk for some purpose.
>
>
> (2) r is the mixing ratio (kg/kg).
>
> (4)  The 'conv_temp' is the minimum of the two quantities.
>        Maybe add this prior to returning
>
>        conv_temp = min(323.15,thccl * (p(1)/100000.0)**RCP)
>        write(6,*) conv_temp, thccl, p(1)
>
> (5) ALso ... upon input ... make sure the data is what you think it should
> be.
>
>       logical is_lfc
>
>       write(6,*) "nlevs=",nlevs
>       do n=1,nlevs
>          write(6,*) 'n =',n,' p=',p(n),' t=',t(n),' r=',r(n)
>       end do
>
> Not sure I can be much ore help.
>
> Regards
> D
>
>
>
> On Wed, Mar 25, 2015 at 7:35 AM, Brandon Sullivan <btsullivan91 at gmail.com>
> wrote:
>
>> Thanks Dennis, I completely understand! I appreciate it very much.
>>
>> Brandon Sullivan
>>
>> On Wed, Mar 25, 2015 at 8:34 AM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> offline
>>>
>>> I work only part-time.
>>>
>>> Hopefully I will have time to look today. I have some of my own job to
>>> do.
>>>
>>> D
>>>
>>> On Tue, Mar 24, 2015 at 4:40 PM, Brandon Sullivan <
>>> btsullivan91 at gmail.com> wrote:
>>>
>>>> All,
>>>>
>>>> I went through and have fixed my arrays and gotten it down to this.. I
>>>> just can't figure out
>>>>
>>>> 1) What is r? Is it water vapor mixing ratio here? I am assuming this,
>>>> and using the ncl function to calculate mixing ratio.
>>>> 2) What units is ctemp provided in? The code is hard to follow for me.
>>>>
>>>> I added print functions to verify my arrays and they look good. Latest
>>>> sounding file attached.
>>>>
>>>>
>>>> Brandon Sullivan
>>>>
>>>> On Tue, Mar 24, 2015 at 9:54 AM, Brandon Sullivan <
>>>> btsullivan91 at gmail.com> wrote:
>>>>
>>>>> This is what I put in this am into my sounding.ncl file
>>>>>
>>>>> ;Add convective temperature
>>>>> ctemp = 0.0 ; init some value
>>>>> p2 = (new_p_mb)*100 ; convert to Pa
>>>>> new_tk = new_tc + 273.15 ; convert to K
>>>>> tk2 = new_tk
>>>>> qv2 = qv/1000
>>>>> levels = new_z
>>>>> CONV::sndganalncl(levels,tk2,p2,qv2,u,v,ctemp)
>>>>>
>>>>> Still not working.. If you're wondering why I had to make some new
>>>>> vars. like that, it's because it didn't like me passing it things with _
>>>>> for some reason?
>>>>>
>>>>> fatal:Number of elements of dimension (0) of argument (0) is (38) in
>>>>> function (sndganalncl), expected (1) elements
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Brandon Sullivan
>>>>>
>>>>> On Mon, Mar 23, 2015 at 11:08 PM, Brandon Sullivan <
>>>>> btsullivan91 at gmail.com> wrote:
>>>>>
>>>>>> Dennis, thanks! I'm 99% there.. WRAPIT worked fine and I was able to
>>>>>> get the soundings to run and generate.. I had to work a little bit with my
>>>>>> variables to line up with my sounding file.. I think I have some bad math
>>>>>> somewhere as all my convective temps are pretty off? Or 0.. I'm unsure
>>>>>> which variable r is referencing here, when looking through the code. I
>>>>>> assume mixing ratio? I've converted it to kg/kg also, but no avail.
>>>>>>
>>>>>> Last step, I hope!
>>>>>>
>>>>>>
>>>>>>
>>>>>> Brandon Sullivan
>>>>>>
>>>>>> On Mon, Mar 23, 2015 at 9:00 PM, Dennis Shea <shea at ucar.edu> wrote:
>>>>>>
>>>>>>> [1]
>>>>>>> The *only* delimieter pair that should be in the code is the 1st
>>>>>>> pair. As noted in the documentation, only the subroutines/functions called
>>>>>>> from NCL should have the delimeters,
>>>>>>>
>>>>>>> [2]
>>>>>>> I think you have 'dos' caharacters embedded in 'test.f'
>>>>>>> Perhaps from the editor you used.?
>>>>>>>
>>>>>>> [3]
>>>>>>> After removing the extra delimiters
>>>>>>>
>>>>>>> %> dos2unix test.f
>>>>>>>
>>>>>>> [4]
>>>>>>> %> WRAPIT test.f
>>>>>>>
>>>>>>> Actually, I'm just attaching what I dd.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Mar 23, 2015 at 3:21 PM, Brandon Sullivan <
>>>>>>> btsullivan91 at gmail.com> wrote:
>>>>>>>
>>>>>>>> Dennis, thanks.
>>>>>>>>
>>>>>>>> I added that.. Added the NCLFORTSTART/NCLEND to it, etc.. Then, I
>>>>>>>> just continued to get a ton of other functions that were undefined... So, I
>>>>>>>> went through and added them all one by one until finally I got no more
>>>>>>>> errors.. I basically have the whole sstats.f file in there..
>>>>>>>>
>>>>>>>> Now, I get this error - warning:Could not find Init() in external
>>>>>>>> file /home/Soundings/Extra/test.so, file not loaded
>>>>>>>> warning:error at line 17 in file testsounding.ncl
>>>>>>>>
>>>>>>>> I do get a syntax error when running WRAPIT now, too.
>>>>>>>>
>>>>>>>> I sincerely appreciate your continued help... New test.f attached.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Brandon Sullivan
>>>>>>>>
>>>>>>>> On Mon, Mar 23, 2015 at 3:34 PM, Dennis Shea <shea at ucar.edu> wrote:
>>>>>>>>
>>>>>>>>> The .so is particular to the compiler you are using. So, it is not
>>>>>>>>> generic.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> The error message is coming from the fortran code
>>>>>>>>>
>>>>>>>>> /home/Soundings/Extra/test.so: undefined symbol: theta_wetb_
>>>>>>>>>
>>>>>>>>> ^^^^^^^^^^^
>>>>>>>>>
>>>>>>>>> If you search for 'theta_wetb' in your test code, it is used but
>>>>>>>>> it is not part of test,f
>>>>>>>>>
>>>>>>>>> Extract that from 'sstats.f' and include with your test.f
>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> *      function theta_wetb(thetae_K)c..c..              Eqn below
>>>>>>>>> was gotten from polynomial fit to data inc..              Smithsonian
>>>>>>>>> Meteorological Tables showing Theta-ec..              and Theta-wc..
>>>>>>>>> real*8 c(0:6), d(0:6)      data c/-1.00922292e-10, -1.47945344e-8,
>>>>>>>>> -1.7303757e-6     +      ,-0.00012709,      1.15849867e-6,
>>>>>>>>> -3.518296861e-9     +      ,3.5741522e-12/      data d/0.00000000,
>>>>>>>>> -3.5223513e-10, -5.7250807e-8     +     ,-5.83975422e-6, 4.72445163e-8,
>>>>>>>>> -1.13402845e-10     +     ,8.729580402e-14/
>>>>>>>>> x=min(475.0,thetae_K)                 if( x .le. 335.5 ) then
>>>>>>>>> answer = c(0)+x*(c(1)+x*(c(2)+x*(c(3)+x*(c(4)+x*(c(5)+     +
>>>>>>>>> x*c(6) )))))      else         answer =
>>>>>>>>> d(0)+x*(d(1)+x*(d(2)+x*(d(3)+x*(d(4)+x*(d(5)+     +            x*d(6)
>>>>>>>>> )))))      endif      theta_wetb = answer + 273.15      return      end---*
>>>>>>>>> The NCL project does have python versions called:  pyNGL and pyNIO
>>>>>>>>> *. *
>>>>>>>>> Likely, they will have new (significantly updated) versions out in
>>>>>>>>> the near future.
>>>>>>>>> No promises but, perhaps, mid-to-late April 2015.
>>>>>>>>>
>>>>>>>>> http://www.pyngl.ucar.edu/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Mar 23, 2015 at 11:30 AM, Brandon Sullivan <
>>>>>>>>> btsullivan91 at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> I have attached my test.so file just in case it helps... Sorry I
>>>>>>>>>> seem so lost here, I am a python person!
>>>>>>>>>>
>>>>>>>>>> Brandon Sullivan
>>>>>>>>>>
>>>>>>>>>> On Mon, Mar 23, 2015 at 11:36 AM, Brandon Sullivan <
>>>>>>>>>> btsullivan91 at gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Using the test.f file that Dennis provided, I was able to run
>>>>>>>>>>> wrapit successfully with no errors.
>>>>>>>>>>>
>>>>>>>>>>> I also went in and added this to my sounding file... With the
>>>>>>>>>>> external command (it was in there before, just somewhere in the middle), to
>>>>>>>>>>> the top with the load commands.
>>>>>>>>>>>
>>>>>>>>>>> "external CONV  "./test.so"
>>>>>>>>>>> ctemp = 0.0        ; create a 'space' for the returned
>>>>>>>>>>> temperature
>>>>>>>>>>> CONV:: sndganalncl(nlevs,t,p,r,u,v,ctemp)"
>>>>>>>>>>>
>>>>>>>>>>> I still get these errors, however.
>>>>>>>>>>>
>>>>>>>>>>> warning:An error occurred loading the external file
>>>>>>>>>>> /home/Soundings/Extra/test.so, file not loaded
>>>>>>>>>>> /home/Soundings/Extra/test.so: undefined symbol: theta_wetb_
>>>>>>>>>>> warning:error at line 17 in file testsounding.ncl
>>>>>>>>>>>
>>>>>>>>>>> Also, now this syntax error -
>>>>>>>>>>>
>>>>>>>>>>> fatal:syntax error: line 472 in file testsounding.ncl before or
>>>>>>>>>>> near :
>>>>>>>>>>> CONV:
>>>>>>>>>>>      ----^
>>>>>>>>>>>
>>>>>>>>>>> New files attached
>>>>>>>>>>>
>>>>>>>>>>> Thanks so much...
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Brandon Sullivan
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Mar 23, 2015 at 11:16 AM, Dennis Shea <shea at ucar.edu>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>  but  betHello,
>>>>>>>>>>>>
>>>>>>>>>>>> At:   https://www.ncl.ucar.edu/Document/Manuals/
>>>>>>>>>>>>
>>>>>>>>>>>> Please read section 7 of the Mini-Language manual
>>>>>>>>>>>> ===
>>>>>>>>>>>> A more detailed description s at:
>>>>>>>>>>>>
>>>>>>>>>>>> https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExtend.shtml
>>>>>>>>>>>> ===
>>>>>>>>>>>> Also of interest: The DKRZ has created two NCL tutorials that
>>>>>>>>>>>> may be of interest.
>>>>>>>>>>>> These are much broader.
>>>>>>>>>>>> ===
>>>>>>>>>>>>
>>>>>>>>>>>> That said .....
>>>>>>>>>>>> [1]
>>>>>>>>>>>> You have a f77 subroutine [ test.f ].  I do not see the
>>>>>>>>>>>> required delimeters
>>>>>>>>>>>>
>>>>>>>>>>>> C NCLFORTSTART
>>>>>>>>>>>> ...
>>>>>>>>>>>> C NCLEND
>>>>>>>>>>>>
>>>>>>>>>>>> These indicate to NCL's f77 parser what information is being
>>>>>>>>>>>> passed back-and-forth between two separate languages.
>>>>>>>>>>>> That is why your code gets the 'A syntax error occurred while
>>>>>>>>>>>> parsing:" message,
>>>>>>>>>>>>
>>>>>>>>>>>> [2]
>>>>>>>>>>>> To use 'external' code (f77, f90, C, C++) you must indicate
>>>>>>>>>>>> that via
>>>>>>>>>>>>
>>>>>>>>>>>>   external TEST "./,,,so"   ; the shared object
>>>>>>>>>>>>
>>>>>>>>>>>> You did not do this.
>>>>>>>>>>>>
>>>>>>>>>>>> [3]
>>>>>>>>>>>> Included in your argument passing, you have
>>>>>>>>>>>>    flminsou,frmaxsou,fbminsou,ftmaxsou
>>>>>>>>>>>> Are these used? NCL does not care but if they are not used, but
>>>>>>>>>>>> why are you passing them?
>>>>>>>>>>>>
>>>>>>>>>>>> [4]
>>>>>>>>>>>> You want 'conv_temp' but you are not passing it back to NCL for
>>>>>>>>>>>> plotting.
>>>>>>>>>>>> In your NCL script ....
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> external CONV  "./test.so"
>>>>>>>>>>>>
>>>>>>>>>>>> ctemp = 0.0        ; create a 'space' for the returned
>>>>>>>>>>>> temperature
>>>>>>>>>>>> CONV:: sndganalncl(nlevs,t,p,r,u,v,ctemp)
>>>>>>>>>>>>
>>>>>>>>>>>> [5]
>>>>>>>>>>>> I have done some mods for your f77 code. That should get you
>>>>>>>>>>>> started.
>>>>>>>>>>>>
>>>>>>>>>>>>    WRAPIT test.f
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Sun, Mar 22, 2015 at 8:43 PM, Brandon Sullivan <
>>>>>>>>>>>> btsullivan91 at gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hello all,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I am trying to use “sstats.f” that I found here -
>>>>>>>>>>>>> http://www.ncl.ucar.edu/Support/talk_archives/2010/att-2526/sstats.f
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I pulled out the code I want and made test.f (attached)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I am trying to use the convective temperature function from
>>>>>>>>>>>>> there and plot it on my soundings (testsounding.ncl)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I try to run WRAPIT and it says this
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>root at ubuntu:/home/Soundings/Extra# WRAPIT test.f
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> WRAPIT Version: 120209
>>>>>>>>>>>>>
>>>>>>>>>>>>> A syntax error occurred while parsing:
>>>>>>>>>>>>>
>>>>>>>>>>>>> COMPILING test.f
>>>>>>>>>>>>>
>>>>>>>>>>>>> LINKING
>>>>>>>>>>>>>
>>>>>>>>>>>>> END WRAPIT”
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Then, when running my sounding script it says
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Copyright (C) 1995-2015 - All Rights Reserved
>>>>>>>>>>>>>
>>>>>>>>>>>>> University Corporation for Atmospheric Research
>>>>>>>>>>>>>
>>>>>>>>>>>>> NCAR Command Language Version 6.3.0
>>>>>>>>>>>>>
>>>>>>>>>>>>> The use of this software is governed by a License Agreement.
>>>>>>>>>>>>>
>>>>>>>>>>>>> See http://www.ncl.ucar.edu/ for more details.
>>>>>>>>>>>>>
>>>>>>>>>>>>> warning:An error occurred loading the external file
>>>>>>>>>>>>> /home/Soundings/Extra/test.so, file not loaded
>>>>>>>>>>>>>
>>>>>>>>>>>>> /home/Soundings/Extra/test.so: undefined symbol: theta_wetb_
>>>>>>>>>>>>>
>>>>>>>>>>>>> warning:error at line 50 in file testsounding.ncl
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Am I going about this wrong? Is there something in the code I
>>>>>>>>>>>>> am missing? I have also tried –m64 when running WRAPIT.. Thanks so much in
>>>>>>>>>>>>> advance!
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Brandon
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>> ncl-talk mailing list
>>>>>>>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>>>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150405/7a4addcc/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsounding_play.ncl
Type: application/octet-stream
Size: 25628 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150405/7a4addcc/attachment.obj 


More information about the ncl-talk mailing list