passing a variable number of args/vectors to a routine
- From: Mirko.Vukovic@xxxxxxxxx
- Date: Wed, 30 Jan 2008 13:24:17 -0800 (PST)
Hello,
I am writing a module to produce TecPlot data files (in ASCII code).
The format of the files is approximately as follows:
title line
Variables="Var1" "Var2" "Var3" ...
more info
then follows columns of data
xxx yyy zzz
xxx yyy zzz
xxx yyy zzz
.... ... ...
The issue is that the number of variables (and data columns) is not
fixed. (I mean it is fixed in a particular program, but can change
from program to program).
I have solved the problem, in my own clunky way, but I wonder if there
is a more effective solution.
For the "VarX" strings, I do the following in the caller routine
! declare and initialize vector of column titles
integer,parameter::cData_Profs=4
character(len=10),dimension(4)::vsProfs=(/"X","A","B","C"/)
! call the TecPlot initialization routine and pass
! cData_Profs and vsProfs
call create_obj(oTime_dep_1dprof, &
& "Time_dep_1dprof.out", "Test of tecplot", &
& cData_pts,cData_profs,vsProfs)
To dump the columns of data, my output routine has the following
arguments
vP1,vP2,vP3,vP4,vP5,vP6,vP7,vP8,vP9
all of which but the first are declared as optional.
Then, to dump the data, I have a select case(cDep_Profs), based on
which I select a write statement
dump_loop: do iData=1,self%cData_pts
select case (self%cDep_Profs)
case (1)
write (self%lu,*) vP1(iData)
case (2)
write (self%lu,*) vP1(iData),vP2(iData)
case (3)
write (self%lu,*) vP1(iData),vP2(iData),vP3(iData)
... etc.
So, is there a better/cleaner way to do all this?
In principle, I could store the data in a matrix, and then print
matrix columns. But this really exposes TecPlot output routine's
internals to the outside world, and I'd like to avoid that.
Thanks,
Mirko
.
- Follow-Ups:
- Prev by Date: Re: Exit code with Fortran 90
- Next by Date: Re: Allocatable Arrays As Outputs
- Previous by thread: Did anyone manage to get MATRAN compiled with g95?
- Next by thread: Re: passing a variable number of args/vectors to a routine
- Index(es):
Relevant Pages
|
|