program ex1 implicit none **** * This program converts climatological monthly surface * temperatures stored in ASCII format * into the RPN standard file format. **** **** * Declare variables used by the RPN standard file library **** character*2 nomvar character*1 typvar, grtyp character*8 etiket integer key, dateo, deet, npas, ni, nj, nk, npak, datyp,yyyymmdd integer ip1, ip2, ip3 integer ig1, ig2, ig3, ig4 **** * Declare the name and type of the RPN standard file functions **** integer fnom, fstouv, fclos, fstfrm, newdate, fstecr external fnom, fstouv, fclos, fstfrm, newdate,fstecr **** * Declare other variables used by the program **** integer ier, nrecs integer i,j,n,iun integer month real fld(120, 60), work(120, 60) **** * Association of the RPN standard file produced by the * program with the FORTRAN logical unit 1. **** iun = 1 ier = fnom(iun, 'TS.FST', 'STD+RND', 0) if (ier.lt.0) then print *, 'Fatal error while opening the file (FNOM)' stop endif **** * Opening of the standard file **** iun = 1 ier = fstouv(iun, 'RND') if (ier.lt.0) then print *, 'Cannot open unit:', iun, * ' in random access mode (FSTOUV)' stop endif **** * Initialization of the standard file attributes that remain * constant for all fields **** typvar = 'C' nomvar = 'TS' etiket = 'SFC TEMP ' ip1 = 0 ip2 = 0 ip3 = 0 ni = 120 nj = 60 nk = 1 deet = 0 npas = 0 grtyp = 'A' ig1 = 0 ig2 = 0 ig3 = 0 ig4 = 0 datyp = 1 npak = -16 **** * Start loop over the 12 months of the year **** do 100 n=1,12 **** * read month and field contents **** read(5, *) month do j=1,60 do i=1,120,5 read(5,*) fld(i,j),fld(i+1,j),fld(i+2,j),fld(i+3,j),fld(i+4,j) enddo enddo **** * Set a date equal the 1st of each month in 1999 **** yyyymmdd = 19990001 + month * 100 ier = newdate(dateo, yyyymmdd, 0, 3) **** * Write a standard file record **** ier = fstecr(fld, WORK, npak, iun, dateo, deet, npas, ni, nj, * nk, ip1, ip2, ip3, typvar, nomvar, etiket, grtyp, * ig1, ig2, ig3, ig4, datyp, .false.) 100 continue **** * Close the standard file **** ier = fstfrm(1) **** * Unlink the unit 1 from the file "ts.fst" **** ier = fclos(1) stop end