[Dart-dev] [3246] DART/branches/nancy_work/preprocess/preprocess.f90: My test branch; *not done* start of obs_def/obs_kind

nancy at subversion.ucar.edu nancy at subversion.ucar.edu
Fri Mar 7 16:29:12 MST 2008


An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20080307/82864f86/attachment.html
-------------- next part --------------
Modified: DART/branches/nancy_work/preprocess/preprocess.f90
===================================================================
--- DART/branches/nancy_work/preprocess/preprocess.f90	2008-03-07 23:27:27 UTC (rev 3245)
+++ DART/branches/nancy_work/preprocess/preprocess.f90	2008-03-07 23:29:12 UTC (rev 3246)
@@ -37,11 +37,11 @@
    revdate  = "$Date$"
 
 ! Pick something ridiculously large and forget about it (lazy)
-integer, parameter   :: max_kinds = 10000
-character(len = 256) :: line, test, kind_string(max_kinds), &
-                        raw_kind_item(max_kinds), t_string
-integer              :: iunit, ierr, io, i, j, k, l, l_kind_string
-integer              :: num_kinds_found
+integer, parameter   :: max_types = 10000
+character(len = 256) :: line, test, type_string(max_types), &
+                        raw_kind_item(max_types), t_string
+integer              :: iunit, ierr, io, i, j, k, l, l_type_string
+integer              :: num_types_found
 logical              :: duplicate
 character(len = 169) :: err_string
 
@@ -145,19 +145,19 @@
 
 ! Output files must NOT EXIST or else an error
 if(.not. file_exist(trim(output_obs_def_mod_file))) then
-   ! Open the file for reading
+   ! Open (create) the file for writing
    obs_def_out_unit = open_file(output_obs_def_mod_file)
 else
-   ! If file does not exist it is an error
+   ! If file *does* exist it is an error
    write(err_string, *) 'file ', trim(output_obs_def_mod_file), ' exists: Please Rename'
    call error_handler(E_ERR, 'preprocess', err_string, source, revision, revdate)
 endif
 
 if(.not. file_exist(trim(output_obs_kind_mod_file))) then
-   ! Open the file for reading
+   ! Open (create) the file for writing
    obs_kind_out_unit = open_file(output_obs_kind_mod_file)
 else
-   ! If file does not exist it is an error
+   ! If file *does* exist it is an error
    write(err_string, *) 'file ', trim(output_obs_kind_mod_file), ' exists: Please Rename'
    call error_handler(E_ERR, 'preprocess', err_string, source, revision, revdate)
 endif
@@ -167,8 +167,8 @@
 ! Easiest to get the three strings required from all of the obs_kind files up front and
 ! then insert stuff
 
-! Initial number of kinds is 0
-num_kinds_found = 0
+! Initial number of types is 0
+num_types_found = 0
 
 SEARCH_INPUT_FILES: do j = 1, num_input_files
    if(file_exist(trim(input_files(j)))) then
@@ -196,7 +196,7 @@
       if(test(1:33) == '! BEGIN DART PREPROCESS KIND LIST') exit FIND_KIND_LIST
    end do FIND_KIND_LIST
 
-   ! Subsequent lines contain the kind_identifier (same as kind_string), and
+   ! Subsequent lines contain the type_identifier (same as type_string), and
    ! raw_kind_ident separated by commas
    EXTRACT_KINDS: do
       read(in_unit, 222, IOSTAT = ierr) line
@@ -211,21 +211,21 @@
       test = adjustl(line)
       if(test(1:31) == '! END DART PREPROCESS KIND LIST') exit EXTRACT_KINDS
 
-      ! Found a kind; increment the count
-      num_kinds_found = num_kinds_found + 1
-      ! Otherwise this line should contain kind_identifier (same as kind_string),
+      ! Found a type; increment the count
+      num_types_found = num_types_found + 1
+      ! Otherwise this line should contain type_identifier (same as type_string),
       ! raw_kind_item with leading comment
       ! Get rid of the leading comment and subsequent space
       test = adjustl(line(2:))
-      ! Compute the length of the kind_string by seeking comma
+      ! Compute the length of the type_string by seeking comma
       do k = 1, 256
-         l_kind_string = k - 1
+         l_type_string = k - 1
          if(test(k:k) == ',') exit
       end do
-      kind_string(num_kinds_found) = adjustl(test(1:l_kind_string))
+      type_string(num_types_found) = adjustl(test(1:l_type_string))
 
       ! Finally get the raw_kind_item
-      raw_kind_item(num_kinds_found) = adjustl(test(l_kind_string + 2:))
+      raw_kind_item(num_types_found) = adjustl(test(l_type_string + 2:))
 
    end do EXTRACT_KINDS
 
@@ -233,7 +233,7 @@
    close(in_unit)
 end do SEARCH_INPUT_FILES
 
-! A list of num_kinds_found kinds has been found, now need to put code into the obs_kind_mod
+! A list of num_types_found kinds has been found, now need to put code into the obs_kind_mod
 ! Begin by copying over lines until first insertion point is found
 do
    read(obs_kind_in_unit, 222, IOSTAT = ierr) line
@@ -253,13 +253,13 @@
 
 ! Loop to write out all the public declarations for types
 51 format(A)
-do i = 1, num_kinds_found
-   write(line, *) 'public :: ', trim(kind_string(i))
+do i = 1, num_types_found
+   write(line, *) 'public :: ', trim(type_string(i))
    write(obs_kind_out_unit, 51) trim(adjustl(line))
 end do
 ! Loop to write out all the public declarations for kinds,
 ! squeezing out duplicates
-do i = 1, num_kinds_found
+do i = 1, num_types_found
    duplicate = .false.
    do j = 1, i-1
       if (trim(raw_kind_item(j)) == trim(raw_kind_item(i))) then
@@ -291,14 +291,14 @@
 end do
 
 ! Write out the integer declaration lines for types
-do i = 1, num_kinds_found
-   write(line, *) 'integer, parameter :: ', trim(adjustl(kind_string(i))), ' = ', i
+do i = 1, num_types_found
+   write(line, *) 'integer, parameter :: ', trim(adjustl(type_string(i))), ' = ', i
    write(obs_kind_out_unit, 51) trim(adjustl(line))
 end do
 
 ! Write out the integer declaration lines for kinds,
 ! squeezing out duplicates
-do i = 1, num_kinds_found
+do i = 1, num_types_found
    duplicate = .false.
    do j = 1, i-1
       if (trim(raw_kind_item(j)) == trim(raw_kind_item(i))) then
@@ -313,7 +313,7 @@
 end do
 
 ! Write out the max_obs_kinds, too
-write(line, *) 'integer, parameter :: max_obs_kinds = ', num_kinds_found
+write(line, *) 'integer, parameter :: max_obs_kinds = ', num_types_found
 write(obs_kind_out_unit, 51) trim(adjustl(line))
 
 ! Copy over lines up to the next insertion point
@@ -334,8 +334,8 @@
 end do
 
 ! Write out the definitions of each entry of obs_kind_info
-do i = 1, num_kinds_found
-   write(line, *) 'obs_kind_info(', i, ') = obs_kind_type(', trim(kind_string(i)), ", '", trim(kind_string(i)), "', &"
+do i = 1, num_types_found
+   write(line, *) 'obs_kind_info(', i, ') = obs_kind_type(', trim(type_string(i)), ", '", trim(type_string(i)), "', &"
    write(obs_kind_out_unit, 21) trim(line)
    write(line, *) '   ', trim(raw_kind_item(i)), ', .false., .false.)'
    write(obs_kind_out_unit, 21) trim(line)
@@ -351,6 +351,8 @@
    ! Write the line to the output file
    write(obs_kind_out_unit, 21) trim(line)
 end do
+
+close(obs_kind_out_unit)
 !_______________________________________________________________________________________
 
 !_______________________________________________________________________________________
@@ -360,7 +362,7 @@
 ! appropriate code from each requested obs_kind file into the output obs_def
 ! file and then proceed.
 
-! There are five special code sections (ITEMS) in the obs_def file at present
+! There are seven special code sections (ITEMS) in the obs_def file at present
 ! That copy code in from the special type specific obs_kind modules
 ! Loop goes to 8 so that stuff after the last item is also copied to the final obs_def_mod.f90
 ITEMS: do i = 1, 8
@@ -393,10 +395,11 @@
    if(i == 2) then
      ! Create use statements for both the KIND_ kinds and the individual
      ! observation type strings.
-     do k = 1, num_kinds_found
-        write(obs_def_out_unit, 21) 'use obs_kind_mod, only : ' // trim(kind_string(k))
+     do k = 1, num_types_found
+        write(obs_def_out_unit, 21) 'use obs_kind_mod, only : ' // trim(type_string(k))
      end do
-     do k = 1, num_kinds_found
+     ! add separation for visual appearance
+     do k = 1, num_types_found
         duplicate = .false.
         do l = 1, k-1
            if (trim(raw_kind_item(k)) == trim(raw_kind_item(l))) then
@@ -471,6 +474,7 @@
 
 end do ITEMS
 
+close(obs_def_out_unit)
 !_______________________________________________________________________________________
 
 


More information about the Dart-dev mailing list