prismdrv_get_all_grids.F90

Go to the documentation of this file.
00001 
00002   SUBROUTINE prismdrv_get_all_grids ( id_nb_grids,       &
00003                                       id_xml_grids,      &
00004                                       sda_smioc_grids,   &
00005                                       id_comp,           &
00006                                       id_error )
00007 
00008 ! !DESCRIPTION
00009 
00010 ! Called from prismdrv_init_smioc_struct for the second pass only 
00011 ! This routine creates all "User-defined" associated gridless grids
00012 ! for each input or output channel that uses a "user3D" interpolation method
00013 !
00014 !---------------------------------------------------------------------------
00015 !
00016 ! !PUBLIC TYPES
00017   USE PRISM_Constants
00018   USE PSMILe_Common
00019   USE PSMILe_smioc
00020   USE PSMILE_smioc_interface
00021 
00022   IMPLICIT NONE
00023 
00024 ! 0. Declaration
00025 !
00026 ! total number of grids (XML + Udef)
00027     INTEGER, INTENT(In) :: id_nb_grids
00028 
00029 ! number of XML grids (read from files)
00030     INTEGER, INTENT(In) :: id_xml_grids
00031 
00032 ! smioc grid  structure
00033     TYPE(smioc_grid), DIMENSION(id_nb_grids), INTENT(InOut) :: sda_smioc_grids
00034 
00035 ! Component id
00036     INTEGER, INTENT(In) :: id_comp
00037 
00038 ! returned error code
00039     INTEGER, INTENT(Out):: id_error
00040 
00041 ! Loop indices
00042     INTEGER :: ib, ib_bis, ib_nt, ib_xml, ib_xmlv, ib_xud
00043     INTEGER :: il_nb, il_nb_bis, il_nb_ter, il_nb_terbis, il_nb_terter
00044     INTEGER :: il_nb_qua, il_nb_cin, il_nb_six, il_nb_hep, il_nb_oct
00045     INTEGER :: il_nb_bisbis
00046     INTEGER :: il_dim_i, il_dim_o, il_ch, il_side
00047 !
00048     CHARACTER(LEN=max_name)  :: cl_name,  cl_out
00049 !
00050 #ifdef DEBUG
00051     print *,"get_all_grids : id_xml_grids    = ", id_xml_grids
00052     print *,"get_all_grids : nb udef grids   = ", iga_comp_nb_udef(id_comp)
00053     print *,"get_all_grids : id_nb_grids     = ", id_nb_grids
00054 #endif
00055 !
00056 !   Return if NO transient with "user3D" interpolation
00057 !
00058     if ( iga_comp_nb_udef(id_comp) == 0 ) RETURN
00059 
00060 !   Second pass only : for each transient involved with User_defined Interp
00061 !                      we need to associate a gridless grid. 
00062 !                      The name of this gridless grid is just the transient local name
00063 !                      with a suffix : _glgrid_I_xx   (or O_xx)                    
00064 !                      where xx is the input-origin  or the output channel number
00065 !
00066 !   Before entering this subroutine, the structure sla_driver_grids is filled
00067 !   from index 1 to id_xml_grids : sla_driver_grids(1:id_xml_grids)
00068 
00069 !   this subroutine creates the structures for the "gridless" grids
00070 !   ib is "global index in component" of the "gridless" additional grids
00071 !      ib values are from id_xml_grids + 1  to id_nb_grids
00072 !
00073     ib = id_xml_grids
00074 
00075 !   Loop on the sga_comp_udef_idx(id_comp)%ig_xml_udef  XML_udef transients
00076     DO ib_xud = 1, sga_comp_udef_idx(id_comp)%ig_xml_udef
00077 
00078 !   Note that for 1 geographic grid, we can have several "gridless" auxilliary
00079 !   grids : 1 for each input origin, or output with user3D interpolation
00080 !   gridless grid index ib is therefore increased in the loop before each creation.
00081 
00082 !   ib_xml is the index of the grid in component SMIOC file 
00083     ib_xml = sga_comp_udef_idx(id_comp)%iga_trans_udef(ib_xud)
00084 #ifdef DEBUG
00085    print *, ' get_all_grids : ib, ib_xud, ib_xml = ', ib, ib_xud, ib_xml
00086 #endif
00087 
00088 !   Get real number of channels of ib_xml transient (In  "AND / OR"  Out)
00089     il_dim_i = sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%ig_dim_orig
00090     il_dim_o = sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%ig_dim_out
00091 
00092     IF ( il_dim_i .GT. 0 )  THEN
00093 
00094 !   Transient In : create gridless grid if flag is .true.  (target side)
00095       DO il_ch = 1, il_dim_i
00096          IF ( sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%  &
00097                     lga_trin_orig(il_ch) ) THEN
00098 #ifdef DEBUG
00099    print *, ' get_all_grids : In,  ib_xml il_ch ib = ', ib_xml, il_ch, ib
00100 #endif
00101             ib = ib + 1
00102             IF ( ib .GT. id_nb_grids ) THEN
00103                PRINT *, '********************************************************'
00104                PRINT *, 'Index overflow in psmile_smioc : prismdrv_get_all_grids '
00105                PRINT *, '********************************************************'
00106                CALL PSMILe_Flushstd
00107                CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00108             ENDIF
00109 !    Internal check on the value of ib_xml
00110             ib_xmlv = sga_comp_udef_idx(id_comp)%iga_xml_trindex(ib-id_xml_grids)
00111             IF ( ib_xmlv .NE. ib_xml ) THEN
00112                PRINT *, '*****************************************************'
00113                PRINT *, 'Index error in psmile_smioc : prismdrv_get_all_grids '
00114                PRINT *, '*****************************************************'
00115                CALL PSMILe_Flushstd
00116                CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00117              ENDIF
00118 !    Create gridless grid structure
00119              il_side = 1
00120 !    Construct grid name from transient name + suffix
00121              cl_name = sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%cg_local_name
00122              call put_udef_suffix ( cl_name, cl_out, il_ch, il_side )
00123              sda_smioc_grids(ib)%cg_grid_name = trim(adjustl(cl_out))
00124 #ifdef VERBOSE
00125   PRINT *, '| | |  '
00126   PRINT *, '| | |  get_all_grids : chan side ib  gridname = ',il_ch, il_side, ib, &
00127                    sda_smioc_grids(ib)%cg_grid_name
00128   CALL PSMILe_Flushstd
00129 #endif
00130 
00131           ENDIF        ! channel is "udef"
00132         ENDDO       ! loop on all input channels
00133       ENDIF      ! il_dim_i > 0
00134 !
00135 !
00136       IF ( il_dim_o .GT. 0 )  THEN
00137         DO il_ch = 1, il_dim_o
00138           IF ( sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%  &
00139                     lga_trout(il_ch) ) THEN
00140 #ifdef DEBUG
00141    print *, ' get_all_grids : Out, ib_xml il_ch ib = ', ib_xml, il_ch, ib
00142 #endif
00143             ib = ib + 1
00144             IF ( ib .GT. id_nb_grids ) THEN
00145                PRINT *, '********************************************************'
00146                PRINT *, 'Index overflow in psmile_smioc : prismdrv_get_all_grids '
00147                PRINT *, '********************************************************'
00148                CALL PSMILe_Flushstd
00149                CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00150             ENDIF
00151 !    Internal check on the value of ib_xml
00152             ib_xmlv = sga_comp_udef_idx(id_comp)%iga_xml_trindex(ib-id_xml_grids)
00153             IF ( ib_xmlv .NE. ib_xml ) THEN
00154                PRINT *, '*****************************************************'
00155                PRINT *, 'Index error in psmile_smioc : prismdrv_get_all_grids '
00156                PRINT *, '*****************************************************'
00157                CALL PSMILe_Flushstd
00158                CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00159              ENDIF
00160 !    Create gridless transient structures
00161              il_side = 0
00162 !    Construct grid name from transient name + suffix
00163              cl_name = sga_comp_udef_idx(id_comp)%sla_driver_udef(ib_xml)%cg_local_name
00164              call put_udef_suffix ( cl_name, cl_out, il_ch, il_side )
00165              sda_smioc_grids(ib)%cg_grid_name = trim(adjustl(cl_out))
00166 #ifdef VERBOSE
00167   PRINT *, '| | |  '
00168   PRINT *, '| | |  get_all_grids : chan side ib  gridname = ',il_ch, il_side, ib, &
00169                    sda_smioc_grids(ib)%cg_grid_name
00170   CALL PSMILe_Flushstd
00171 #endif
00172 
00173           ENDIF      ! channel is "udef"
00174        ENDDO       ! loop on all output channels
00175      ENDIF      ! il_dim_o > 0
00176 !
00177      ENDDO            !  loop on "xml udef" transients to be copied
00178 
00179 !
00180   END SUBROUTINE prismdrv_get_all_grids

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1