JDruryPhys
Programmer
Hi all,
I have a problem with a Fortran script I am trying to use for a research project. I have several data sets and I wish to be able to process them using the one Fortran script. This is a script I have been provided with and my knowledge is very basic (I have had about 4 days to try to cram in as much knowledge about Fortran as possible). I have a file (qxlc.flags where the x is the dataset number e.g. q1lc.flags, q2lc.flags etc.) in the same directory for each data set as this script which has approximately 4000 lines with the last line of the file being the number of lines above it, format: "__4370_" where the '_'s are spaces (the exact number differs for each data set). What I wish to do is get the number of lines from the end of the qxlc.flags file and use it in the code. I have included some of the code below. Lines marked ##### Contain what I want to do and while I could enter these values manually, I have a lot of datasets and so would prefer to enter them automatically if possible. Any help would be much appreciated.
J.Drury
I have a problem with a Fortran script I am trying to use for a research project. I have several data sets and I wish to be able to process them using the one Fortran script. This is a script I have been provided with and my knowledge is very basic (I have had about 4 days to try to cram in as much knowledge about Fortran as possible). I have a file (qxlc.flags where the x is the dataset number e.g. q1lc.flags, q2lc.flags etc.) in the same directory for each data set as this script which has approximately 4000 lines with the last line of the file being the number of lines above it, format: "__4370_" where the '_'s are spaces (the exact number differs for each data set). What I wish to do is get the number of lines from the end of the qxlc.flags file and use it in the code. I have included some of the code below. Lines marked ##### Contain what I want to do and while I could enter these values manually, I have a lot of datasets and so would prefer to enter them automatically if possible. Any help would be much appreciated.
J.Drury
Code:
program savecl
c this set up for dataset 3
c *** NOTE: entries 'nv' and 'ndat' need updating for each new dataset. Comments underneath corresponding lines.
character*10 qxlcnme
c name of file for dataset x
integer nlines
c Line number for position of last line in file
parameter(nv=52481520,nap=20)
c nv is a value found by: ls -l *.fits | awk '{if(NR==1) print $5/4}' in the same directory as the script. #####
parameter(ntot=40000,nsng=2000)
c constants for code.
parameter(ndat=4370)
c Number of lines in qxlc.flags file. I wish to change this to ndat = nlines somehow. #####
parameter(nbuf0=9204,nbufg=10007)
c start and general step skips
dimension vectin(nv),vectall(ndat*nsng,nap),d1(ntot)
c vectall will have saved only the active data sections
dimension ifl(ndat)
character*3 istat
character*10 cflags
character*41 fdata
character*9 chd1
character*9 filset
data exps/1625.4/
c ##### My current attempt to get the values I want, failed as I can't set variable values before I have found the value and apparently can't assign them afterwards either.
open(unit=60,file='qxlc.txt')
read(60,*) qxlcnme
close(60)
open(unit=66,file=qxlcnme)
do
read(66,*,END=70)
nlines=nlines+1
enddo
70 close(66)
ndat = nlines
##### End of attempt... Code continues.
c open deck file
open(unit=5,file='savecl.deck')
read(5,20) filset,cflags,istat,chd1
write(6,20) filset,cflags,istat,chd1
20 format(a9,1x,a10,1x,a3,1x,a9)
close(unit=5)
.----------------------------------------------
. There is more code here but I don't think its needed for this question. If extra detail is needed, please let me know.
.----------------------------------------------
end