- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using the following compiler version intel/compiler/64/14.0/2013_sp1.2.144. In writing namelists to a file, the compiler writes repeat counts of elements in an array. How do I avoid it? For example the ouput file (modified.nml) from the "program io" contains
&MY_BUNDLE NUMBOOKS = 7, INITIALISED = T, NAME = 'julliet ', VEC = 4*2.000000
/
whereas i am expecting
&MY_BUNDLE NUMBOOKS = 7, INITIALISED = T, NAME = 'julliet ', VEC = 2.000000, 2.000000, 2.000000, 2.000000
/
Please find the test program I used.
program io implicit none ! local variables, all left without values assigned integer, parameter :: strlen = 50 ! convenient & flexible integer :: numBooks logical :: initialised character(len=strlen) :: name real, dimension(4) :: vec integer :: ios ! for checking status ! group variables into a namelist called 'example_nml' namelist /my_bundle/ numBooks,initialised,name,vec ! open the input file containing the data open(unit=56,file='input.nml',status='old',iostat=ios) if (ios /= 0) then print*,'ERROR: could not open namelist file' stop end if ! read data into the declared namelist read(UNIT=56,NML=my_bundle,IOSTAT=ios) if (ios /= 0) then print*,'ERROR: could not read example namelist' stop else close(56) end if write (*,*) "=====Variables read from file have values:=====" write (*,*) numBooks write (*,*) name write (*,*) initialised write (*,*) vec ! modify values 'programatically' numBooks = 7 initialised = .true. name = 'julliet' vec = (/2.0, 2.0, 2.0 , 2.0/) ! open a new file for writing Open(unit=56, file='modified.nml', form='FORMATTED', delim='APOSTROPHE', carriagecontrol='NONE') iF (ios /= 0) then print*,'ERROR: could not open new namelist file' stop end if ! now write the modified data write(UNIT=56,NML=my_bundle,IOSTAT=ios) if (ios /= 0) then print*,'ERROR: could not read example namelist' stop else close(56) end if write (*,*) write (*,*) "=====modified values written to modified.nml, compare the files=====" end program io
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't provide an option to avoid the repeat counts. This is a Fortran standard behavior. Why are you "expecting" the value to be repeated? The output you get is processed properly by NAMELIST input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The output files containing NAMELIST are read by unix scripts for post processing (which cannot read repeat counts).
For Cray/SGI compilers we can use ASSIGN environment
CALL ASNFILE (fname,astring,ier)
to suppress repeat counts. Do we have similar functionality in INTEL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't provide the ability to suppress repeat counts. We do have various attributes that can be controlled through environment variables, but that's not one of them. I'll comment that NAMELIST output has a LOT of flexibility in what the "processor" does and it's not surprising that a script written for one compiler doesn't work in another.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should be able to easily write a script file to expand the repeat counts and run that as the first step of your post processing.
Steve, my read of Karthee's post is it is a non-Fortran application or script that is performing the post processing, and Karthee wanted a quick fix. Someone reading this may be willing to suggest a simple AWK or Python script that parses lines into tokens, passes all tokens excepting for tokens of the format n*whatWouldBeAToken, then emit the corrected string inclusive of commas.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I understood Karthee's problem - but there is no quick fix. Karthee's script relies on implementation-dependent formatting.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page