Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

declaring character type

jerryjerry
Beginner
836 Views
my code uses parameter files to type. Here is a copy of the problem file:
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CS TARGET PARAMETERS
CHARACTER*10
& TARGET_DATABASE_FILENAME ! facet database filename
REAL
& TARGET_SPEED, ! (m/s)
& TARGET_HEADING, ! (deg from North)
& TARGET_ROLL_AMPLITUDE, ! -max <= roll <= +max (deg)
& TARGET_ROLL_FREQ, ! roll cycle (Hz)
& TARGET_ROLL_INIT, ! roll at time=0 (deg)
& TARGET_ROLL_AVERAGE, ! (deg from vertical)
& TARGET_PITCH_AMPLITUDE, ! -max <= pitch <= +max (deg)
& TARGET_PITCH_FREQ, ! pitch cycle (Hz)
& TARGET_PITCH_INIT, ! pitch at time=0 (deg)
& TARGET_PITCH_AVERAGE, ! (deg from forward horizon)
& TARGET_YAW_AMPLITUDE, ! -max <= yaw <= +max (deg)
& TARGET_YAW_FREQ, ! yaw cycle (Hz)
& TARGET_YAW_INIT, ! yaw at time=0 (deg)
& TARGET_YAW_AVERAGE, ! (deg from vertical)
& SCAT_SPACING ! spacing of scatter centers
COMMON/TARGET_PARMS/
& TARGET_DATABASE_FILENAME,TARGET_SPEED,TARGET_HEADING,
& TARGET_ROLL_AMPLITUDE,TARGET_ROLL_FREQ,TARGET_ROLL_INIT,
& TARGET_ROLL_AVERAGE, TARGET_PITCH_AMPLITUDE,
& TARGET_PITCH_FREQ,TARGET_PITCH_INIT,TARGET_PITCH_AVERAGE,
& TARGET_YAW_AMPLITUDE,TARGET_YAW_FREQ,TARGET_YAW_INIT,
& TARGET_YAW_AVERAGE,SCAT_SPACING
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
I added a line to settings/compiler options: /align:"commons" . Without this adddition, the program compiled with hundreds of eror messages about alignment problems.
Now, the program compiles, and runs, but only when the 'Target_filename" is exactly 10 characters. This is very inconvenient. Can you tell me what I'm doing wrong?

Jerry
0 Kudos
10 Replies
james1
Beginner
836 Views
What doesn't work when TARGET_DATABASE_FILENAME is something other than ten characters? Is there an error? And do you mean the definition of that variable, or the length of the filename assigned to that variable?

Be sure any code accessing the common has been recompiled with the new option.

James
0 Kudos
jerryjerry
Beginner
836 Views
When I 'run'the program, it asks for the 'arget_filename'. If the name of the file is exzcly 10 characters, the program runs tttttsuccessfully to completion. However, if I use a target_filename other than 10 characters, the error message is "cannot find the file" (and the requested filename is shown onscreen).
0 Kudos
james1
Beginner
836 Views
Without seeing the code that fills in the variable, I can guess that the result is a filename that has something other than trailing spaces in the filename variable. Try initializing it to ' ' before inquiring for the name of the file.

James
0 Kudos
jerryjerry
Beginner
836 Views
The executable runs to completion when the requested 'target_filename' is exactly 10 characters long. For file_names other that 10 characters, it "cannot find file" of the name -----.
0 Kudos
james1
Beginner
836 Views
Before you actually try to OPEN the file, you should look in the debugger or otherwise at the contents of the TARGET_DATABASE_FILENAME variable. You will likely find that when you have less than ten characters that you have some spurious characters immediately following the filename. If not, I'd recommend posting a code snippet that demonstrates the problem.

James
0 Kudos
durisinm
Novice
836 Views
Fortran 77 required storing character variables in their own COMMON blocks separate from all other data types. I don't know if VF has this requirement or not since it can accept Fortran 95 syntax. Variables in COMMON blocks holding non-character data types should be arranged in order of largest storage units to smallest.

You could try replacing your COMMON blocks with modules instead.

Mike
0 Kudos
Steven_L_Intel1
Employee
836 Views
CVF allows mixing CHARACTER and non-CHARACTER in a COMMON, as F90/F95 does, but the standard does not specify the "Common association" behavior when a character and non-character value share the same position in the common.

Steve
0 Kudos
jerryjerry
Beginner
836 Views
What does not work?: The error message comes up: "Cannot find the file xyz.sta" and then another series of error messages before bombing out.

I re-wrote the parameter file without the character*10 declaration and then went into the code, and declared the character*10 everywhere that I had 'included' the reference in the using parameter file. Same result!

I'm beiginning to think that the problem is with DOS. The program file name is entered from the command line. However, this is in contradiction to the fact that the program does run successfully when the filename size matches the declaration. For example, with declaration: character*10, the program runs if the name of the file is made to be "747_08-13A.sta". Now I change the name to "747.sta" and it "cannot find the file 747.sta"
0 Kudos
gfthomas8
Novice
836 Views
character*10 expects the file to have 10 characters, no more and no less.
0 Kudos
Steven_L_Intel1
Employee
836 Views
Can you come up with a SHORT but complete program that reproduces the problem? I'm guessing that the issue is somewhere other than where you're looking, and has little to do with the way you declare the CHARACTER variable.

Steve
0 Kudos
Reply