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