Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How to write the output to the file based on the "user-selected"
Hi All,

I am working in a project, which is a simple VB GUI calls CVF DLL,
user can set up a bunch of parameters in GUI and trigger the
calculation of Fortran model by calling the DLL,  then some output
data will be write into the file where GUI can retrieve them to show
back to the user.

Since there are a lot of variables in my Fortran calculation model
(more than 1000 and most of them are real value), it's not necessary
to show all of them to the user (all of these variables will be
calculated in the model though), so user can select the variables in
the GUI which they wanna see in the output part...

for instance,
I have a variable list includes 10 variables : varA,varB, varC,...,
VarJ, all of them will be calculated in the model and get a real value
eventually. But user may only wanna see some of them, let's say: varA
and VarD for example.

My problem is : how can I just only write the values of those "user-
selected" variables to the output file?
I mean, do I have to pass an "array of string" which contains "user-
selected variables" from GUI to my Fortran model? or just save these
"user-selected variables" in a tmp data file, and Fortran model can
read them later when it starts the output generate part.
And under the both circumstances, how can I use the "write" statement
in detail.

Thanks in advances for any comments or suggestions.



Report this thread to moderator Post Follow-up to this message
Old Post
dw1725
04-02-08 03:39 AM


Re: How to write the output to the file based on the "user-selected"
dw1725 ha scritto:
> I mean, do I have to pass an "array of string" which contains "user-
> selected variables" from GUI to my Fortran model?

As far as I know (but I may be wrong), you cannot do something like
this. You cannot retrieve the name of a variable from inside the program
to which it belongs. The human-readable names of the variables are not
even stored in the executable (unless some debug option is used).

Somewhere in the code you will have to hard-code a map from human-names
to computer variables, something like:

if(save_this=='varA') write(*,*) varA

iterated for all of the variables you wish to show.

Of course you can do something smarter than a list of ifs. I would
probably use an array of a derived type; the type will contain a string
(the variable name) and a pointer (set to point the corresponding
variable). Something like this:

TYPE variables_index
CHARACTER(len=5) :: name
REAL(DP),POINTER :: value
END TYPE variables_index

TYPE(variables_index) :: vindex(10)

vindex(1)%name  = 'varA'
vindex(1)%value => varA
...

If you variables have different kinds it get trickier, but is still
feasible with a single derived type.

Hope this helps

P.S. this kind of stuff is very easy to do with interpreted languages,
like java or python.

--
Lorenzo `paulatz' Paulatto
Trieste

``Grandissima mi par l'inezia di coloro che vorrebbero che Iddio avesse
fatto l'universo pił proporzionato alla piccola capacitą del lor discorso.''
--Galileo Galilei (Opere VII)

Report this thread to moderator Post Follow-up to this message
Old Post
Lorenzo `paulatz' Paulatto
04-02-08 03:39 AM


Re: How to write the output to the file based on the "user-selected"
Lorenzo `paulatz' Paulatto wrote:
> dw1725 ha scritto:
 

> As far as I know (but I may be wrong), you cannot do something like
> this. You cannot retrieve the name of a variable from inside the program
> to which it belongs. The human-readable names of the variables are not
> even stored in the executable (unless some debug option is used).

If you use NAMELIST then the names are stored, likely along with
the addresses so that namelist I/O works.   Namelist input allows
one to specify a selected set of input variables by name.
Namelist output writes all the variables in the list.

-- glen


> Somewhere in the code you will have to hard-code a map from human-names
> to computer variables, something like:
>
> if(save_this=='varA') write(*,*) varA
>
> iterated for all of the variables you wish to show.
>
> Of course you can do something smarter than a list of ifs. I would
> probably use an array of a derived type; the type will contain a string
> (the variable name) and a pointer (set to point the corresponding
> variable). Something like this:
>
> TYPE variables_index
>   CHARACTER(len=5) :: name
>   REAL(DP),POINTER :: value
> END TYPE variables_index
>
> TYPE(variables_index) :: vindex(10)
>
> vindex(1)%name  = 'varA'
> vindex(1)%value => varA
> ...
>
> If you variables have different kinds it get trickier, but is still
> feasible with a single derived type.
>
> Hope this helps
>
> P.S. this kind of stuff is very easy to do with interpreted languages,
> like java or python.
>


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
04-02-08 03:39 AM


Re: How to write the output to the file based on the "user-selected"
On Apr 1, 10:24=A0am, dw1725 <dw1...@gmail.com> wrote:
> Hi All,
>
> I am working in a project, which is a simple VB GUI calls CVF DLL,
> user can set up a bunch of parameters in GUI and trigger the
> calculation of Fortran model by calling the DLL, =A0then some output
> data will be write into the file where GUI can retrieve them to show
> back to the user.
>
> Since there are a lot of variables in my Fortran calculation model
> (more than 1000 and most of them are real value), it's not necessary
> to show all of them to the user (all of these variables will be
> calculated in the model though), so user can select the variables in
> the GUI which they wanna see in the output part...
>
> for instance,
> I have a variable list includes 10 variables : varA,varB, varC,...,
> VarJ, all of them will be calculated in the model and get a real value
> eventually. But user may only wanna see some of them, let's say: varA
> and VarD for example.
>
> My problem is : how can I just only write the values of those "user-
> selected" variables to the output file?
> I mean, do I have to pass an "array of string" which contains "user-
> selected variables" from GUI to my Fortran model? or just save these
> "user-selected variables" in a tmp data file, and Fortran model can
> read them later when it starts the output generate part.
> And under the both circumstances, how can I use the "write" statement
> in detail.
>
> Thanks in advances for any comments or suggestions.
Lorenzo has given you a good answer to work from.

Another thing to think about : Using the file system to transfer
information in this manner can be chancy. Even if you 'flush' output
buffers and close the output file, some OSs buffer output to file
systems. Notoriously, Windows can have a 'lazy' write to disk, where
the values you want to read might not be available by opening and
reading from the GUI. (I've run into this problem).  You might
consider looking into Interprocess Communication (IPC) that might be
available for your operating system/languages. Examples are shared
memory, named pipes, ....

Glen also has a viable solution. I've used NAMELIST effectively in
such instances. However the problem remains that the file information
might not be available to the GUI if the OS can't *really* flush the
output to the file system.

--
jon


Report this thread to moderator Post Follow-up to this message
Old Post
jon
04-02-08 03:39 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:14 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.