- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the simplified logic of the part that I am working on in my program.
There is a main input file with the extension of *.dat
1. When my program find the character string transient boundary condition (TBC) in it,
2. program looks for *.chm data file.
a. If there is no *.chm file, then stop and print error message to the screen/output file.
b. If *.chm file exists,
i. Open/read it
ii. Calculate transient boundary chemistry
This is what I am trying to do. At this point, even though I have TBC in input file and dont have *.chm, my program keep calculating other things. It must stop and print error message!!!
I think there must be very simple (and stupid T.T) mistakes, but I cannot find it. Please take a look at my source file and give me some suggestions. Thanks.
c ----------------------------------------------------------------------
c subroutine initchm
c -------------------
c
c written by: Harry Kim - July __, 2004.
c
c variables have already declaired in other modules or subroutines
c ----------------------------------------------------------------------
subroutine initchm
use gen
use parm
use chem
implicit real*8 (a-h,o-z)
character subsection
logical found_subsection
external findstrg, intpolchm, opnchm
c assign transient boundary chemistry
subsection = 'transient boundary chemistry'
call findstrg (subsection,itmp,found_subsection)
if (found_subsection) then
update_chm = .true.
c else
c return
end if
c open file containing transient boundary chemistry (TBC) data
c and read initial boundary chemistry data
if (update_chm) then
call opnchm
c interpolate time-dependent chemistries on grid
call intpolchm
else
c goto 999
return
end if
c debugging information
info_debug = 0
c transient boundary chemistry
do ichem = 1,nchm
write(idbg,*) 'trschm(ichem) ',trschm(ichem)
end do
if (info_debug.gt.1) then
stop
end if
999 write(ilog,*) 'SIMULATION TERMINATED'
write(ilog,*) 'file ', prefix(:l_prfx)//'.chm missing'
stop
return
end
Message Edited by Harry27606 on 07-08-2004 12:58 AM
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN(Some_unit, file="Some_File", STATUS="OLD", IOSTAT=iError) IF (iError.NE.0) THEN Stop "File "//"Some_File"//" does not exist"! END IF
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
c ----------------------------------------------------------------------
c subroutine opnchm
c ------------------
c
c open *.chm file containing transient boundary chemistry
c
c written by: Harry Kim - July __, 2004
c
c last modified:
c
c definition of variables:
c
c I --> on input * arbitrary - initialized + entries expected
c O --> on output * arbitrary - unaltered + altered
c
c I O
c passed: -
c
c common:
c gen.f: integer*4:
c ----------
c ichm = unit number, transient boundary
c chemistry - +
c chem.f: real*8:
c -------
c dt_chm = time increment in transient boundary - +
c chemistry file
c chm_read = time to read next boundary - +
c chemistry
c schm(nit) = time steps of specified input
c chemistry
c local: integer*4:
c ----------
c nchm = number of components related to - +
c chemistry input
c it = counter (inlet chemistry points)
c nit = number of input time (tbc)
c
c ----------
c logical:
c --------
c
c character:
c ----------
c
c external: mem_chm = allocate memory for one-dimensional arrays
c of size nchmp
c ----------------------------------------------------------------------
subroutine opnchm
use parm
use gen
use chem
implicit real*8 (a-h,o-z)
integer it
external mem_chm
c define unit number
ichm = 17
c open file containing transient boundary chemistry
open(ichm,file=prefix(:l_prfx)//'.chm', err=999, status='old')
read(ichm,*,err=998,end=998) time_chm
c open(ichm,file=prefix(:l_prfx)//'.chm',err=999, status='old')
c open(ichm,file=prefix(:l_prfx)//'.cbcvs',err=997, status='old')
c read time interval, number of data points and associated depths
c and allocate memory
read(ichm,*) dt_chm, nit
call mem_chm
backspace(ichm)
read(ichm,*) dt_chm, nit, (schm(it),i=1,nit)
chm_read = dt_chm
c read initial input boundary chemistry data
read(ichm,*) (chm(it),it=1,nit)
998 write(ilog,*) 'SIMULATION TERMINATED'
write(ilog,*) 'error reading file ', prefix(:l_prfx)//'.chm'
stop
999 write(ilog,*) 'SIMULATION TERMINATED'
write(ilog,*) 'file ', prefix(:l_prfx)//'.chm missing'
stop
return
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page