COMMON block question [message #23576] |
Tue, 30 January 2001 07:53  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Hey there,
I am doing the following in an initialisation function:
COMMON rtm_transmittance_data, predictor_index, $
transmittance_coefficients
result = read_transmittance_coefficients( 'transmittance_coefficients', $
predictor_index, $
transmittance_coefficients )
IF ( result NE SUCCESS ) THEN $
MESSAGE, 'Error reading transmittance coefficients.', $
/NONAME, /NOPRINT
If I run the function I see the following:
IDL> print, initialize_rtm()
% Compiled module: COMPUTE_ABSORBER_SPACE.
% Compiled module: READ_TRANSMITTANCE_COEFFICIENTS.
% Compiled module: OPEN_COEFFICIENT_FILE.
% Compiled module: READ_SPECTRAL_COEFFICIENTS.
1
IDL> common rtm_transmittance_data
IDL> help
% At $MAIN$
PREDICTOR_INDEX (RTM_TRANSMITTANCE_DATA)
LONG = Array[6, 142, 3]
TRANSMITTANCE_COEFFICIENTS (RTM_TRANSMITTANCE_DATA)
DOUBLE = Array[6, 301, 142, 3]
Compiled Procedures:
$MAIN$
Compiled Functions:
COMPUTE_ABSORBER_SPACE INITIALIZE_RTM OPEN_COEFFICIENT_FILE
READ_SPECTRAL_COEFFICIENTS READ_TRANSMITTANCE_COEFFICIENTS
How does IDL go about creating COMMON blocks when the size/type of the common block
elements are not known until, in this case, they're read in. Understand I'm coming from
Fortran-90 background where I declare everything up front in its own module (sort of like
a f77/IDL common block but better). Does IDL simply create pointers to the data elements
up front and then fills in the blanks after the data has actually been read in/defined?
The documentation doesn't give much info.
Thanks for any insights. All metphysical replies forwarded to DF. :o)
paulv
--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301) 763-8000 x7274 There shallow draughts intoxicate the brain,
Fax: (301) 763-8545 And drinking largely sobers us again.
Email: pvandelst@ncep.noaa.gov Alexander Pope.
|
|
|
|
|
|
Re: common block question [message #75905 is a reply to message #23576] |
Fri, 15 April 2011 09:13  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Paulo Penteado wrote:
> On Apr 15, 7:02 am, geoff <oxfordenergyservi...@googlemail.com> wrote:
>> Thanks for all your above comments. One of my issues is that I may
>> have to re-code in fortran or C and run on a parallel machine (or may
>> not!). I would prefer to write the program in IDL in a way that is
>> relatively transferrable to fortran95 ultimately, which is why I
>> considered common blocks which turn into modules that can be called in
>> fortran.
>
> I also had on many occasions to suffer from global variables through
> Fortran modules.
And, not to pile on, but module variables in Fortran are inherently not threadsafe.
> Structures, pointers and objects as I suggested above are all pretty
> much possible to directly translate to Fortran.
As well as some of the OOP stuff as well (assuming you have a compiler that is compliant with the OOP stuff in Fortran2003).
cheers,
paulv
|
|
|
Re: common block question [message #75907 is a reply to message #23576] |
Fri, 15 April 2011 08:33  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Apr 15, 7:02 am, geoff <oxfordenergyservi...@googlemail.com> wrote:
> Thanks for all your above comments. One of my issues is that I may
> have to re-code in fortran or C and run on a parallel machine (or may
> not!). I would prefer to write the program in IDL in a way that is
> relatively transferrable to fortran95 ultimately, which is why I
> considered common blocks which turn into modules that can be called in
> fortran.
I also had on many occasions to suffer from global variables through
Fortran modules.
Structures, pointers and objects as I suggested above are all pretty
much possible to directly translate to Fortran.
|
|
|
Re: common block question [message #75908 is a reply to message #75713] |
Fri, 15 April 2011 03:02  |
oxfordenergyservices
Messages: 56 Registered: January 2009
|
Member |
|
|
On Apr 14, 3:20 pm, Paolo <pgri...@gmail.com> wrote:
> On Apr 13, 3:15 pm, geoff <oxfordenergyservi...@googlemail.com> wrote:
>
>> I am writing a program which will call a number of subroutines. I
>> have a number of arrays, the largest of which (and will take a
>> significant part of the memory) will be used in most (but not all) of
>> the subroutines, will be created at the beginning and be retained
>> until the end of the program.
>
> I would make this an object with the subroutines as methods.
>
> Ciao,
> Paolo
>
Thanks for all your above comments. One of my issues is that I may
have to re-code in fortran or C and run on a parallel machine (or may
not!). I would prefer to write the program in IDL in a way that is
relatively transferrable to fortran95 ultimately, which is why I
considered common blocks which turn into modules that can be called in
fortran.
|
|
|